Easy Thematic Favicons

Continuing with my modest efforts to post some useful Thematic/WordPress snippets, here's some code to provide favicons for WordPress sites using Thematic child themes. Simply add this code to your child theme's functions.php page:


// Add favicons to the child theme
function childFavicons() { ?>
<link rel="icon" type="image/png" href="/wp-content/themes/childtheme/images/favicon_16x16.png" />
<link rel="icon" type="image/png" href="/wp-content/themes/childtheme/images/favicon_32x32.png" />
<link rel="icon" type="image/png" href="/wp-content/themes/childtheme/images/favicon_64x64.png" />
<?php }
add_action('wp_head','childFavicons');

Here's a variation to provide different favicons for two different versions of the same site, for example for staging and live sites:


// Add favicons to the child theme
function childFavicons() {
//detect if is live site
if (strtolower($_SERVER["HTTP_HOST"] == "www.domain.com"))
{ ?>
<link rel="icon" type="image/png" href="/wp-content/themes/childtheme/images/favicon_16x16.png" />
<link rel="icon" type="image/png" href="/wp-content/themes/childtheme/images/favicon_32x32.png" />
<link rel="icon" type="image/png" href="/wp-content/themes/childtheme/images/favicon_64x64.png" />
<?php } elseif (strtolower($_SERVER["HTTP_HOST"] == "stg.domain.com"))
{ ?>
<link rel="icon" type="image/png" href="/wp-content/themes/childtheme/images/stg_favicon_16x16.png" />
<link rel="icon" type="image/png" href="/wp-content/themes/childtheme/images/stg_favicon_32x32.png" />
<link rel="icon" type="image/png" href="/wp-content/themes/childtheme/images/stg_favicon_64x64.png" />
<?php }
}
add_action('wp_head','childFavicons');

Should work OK - let me know in the comments if you have any probs.


Digg This
Reddit This
Stumble Now!
Share on Facebook
Bookmark this on Delicious
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Buzz this!


Printed from: http://www.divydovy.com/2010/06/easy-thematic-favicons/. © divydovy 2017

Leave a Reply