Post Pic

Add a favicon to your WordPress blog using a hook

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!

2 Responses

Jan 20 2012 00:44

You don’t need to echo ‘bloginfo()’ – if it was ‘get_bloginfo()’ you would.

Jan 20 2012 00:46

and as a rule it’s better to (i prefer to) close the link ‘/>’

Other than that great info.

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required