Site icon WP Smith

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]