Add a favicon to your WordPress blog using a hook

February 1, 2010 at 8:11 am

Nowadays, any serious blog have its own favicon. To add yours into WordPress, you can directly edit header.php or you can use a more clean technique, using the power of WordPress hooks.

Just paste the following into your function.php file, save it, and you’re done.

function childtheme_favicon() { ?>
	<link rel="shortcut icon" href="<?php echo bloginfo('stylesheet_directory') ?>/images/favicon.png" > 
<?php }
add_action('wp_head', 'childtheme_favicon');

Don’t forget to change the favicon url if needed. Also, please note that if the wp_head() function haven’t been implemented in your theme, this recipe will not work.

By the way, if you’re looking for premium WordPress themes and plugins, just have a look to the dedicated category on CouponsForBloggers.com!

Tags: