WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Sep 22 2010

Different Favicons for WordPress 3.0 Multisite

Before WordPress 3.0 appeared, I had a different favicon for each of my WordPress sites; however, when I finally made the switch to one WordPress install with Multisite and Domain Mapping, I found that I lost all the various favicons. Typically I use the same two frameworks, and I guess I could create various child theme folders for each site, which would work! However, I'm too lazy to do that and everything that it would entail on enabling themes in the SuperAdmin, etc. (although it would be great to be able to enable themes based on roles!).

So here is what I did in my functions.php file to enable each site in my Multisite installation to have their own favicon. But first, you must place the favicons in the appropriate files folder under wp-content/blogs.dir. So you will need to know the site's ID number, which can be found under the Super Admin > Sites (mydomain.com/wp-admin/ms-sites.php).

[php]/* Different Favicon for Each Site in MS */
function favicon4sites() {
echo '<link rel="Shortcut Icon" type="image/x-icon" href="' . get_bloginfo('wpurl') . '/files/favicon.ico" />';
}
add_action( 'admin_head', 'favicon4sites' );
add_action( 'login_head', 'favicon4sites' );
add_action( 'wp_head', 'favicon4sites' );[/php]

If you wanted, you can write different functions to allow for different favicons for the login screen and the admin section but don't forget to remove add_action( 'login_head', 'favicon4sites' ); and add_action( 'wp_head', 'favicon4sites' ); from the previous edit.

[php]/* Different Favicon for the Admin */
function favicon4admin() {
echo '<link rel="Shortcut Icon" type="image/x-icon" href="' . get_bloginfo('wpurl') . '/wp-content/favicon.ico" />';
}
add_action( 'admin_head', 'favicon4admin' );
[/php]

Also note that you can use *.png or *.gif, but they won't work in IE:

[html]<link rel="icon" href="/favicon.png" type="image/png">
<link rel="icon" href="/favicon.gif" type="image/gif"> [/html]

Written by Travis Smith · Categorized: Tutorials

StudioPress Premium WordPress Themes     WP Engine Managed WordPress Hosting

What can I do for you!?

Custom Development

We develop plugins by determining both business/functional and technical requirements, following WordPress development best practices, and using agile methodology to ensure you get the best solution.

Consulting

Have questions? Need a reliable developer to consult? Please contact us today!

Customized Theme

We can customize your theme or child theme, or create a child theme for you based on your needs while enhancing the performance of every individual attribute.

Customized Plugin

We can customize your plugins, extend plugins (e.g., Gravity Forms, Jetpack, Soliloquy) based on your needs ensuring security, performance, and positive business impact.

Contact Us

About Travis Smith

As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

Comments

  1. Brandon says

    March 28, 2011 at 12:18 pm

    Thanks for this information! I was considering using one of the favicon plugins that support this setup, but I think I might go this route because sometimes I prefer hard-coded functions over relying on a plugin.

    On a side note, how do you get your code examples to appear as they do on your site?

    Reply
    • Travis Smith says

      March 28, 2011 at 1:24 pm

      I use Syntax Highlighter Evolved by ViperBond007.

      Reply
  2. Paul says

    July 3, 2014 at 1:45 pm

    Curious which functions.php file you placed that in? In the primary domains theme file functions.php ? Thanks

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in