How to Use Your Gravatar As the Favicon For Your WordPress Site

It doesn’t matter what kind of site you have, you absolutely need a favicon. It identifies your site within the the browser’s address bar and tabs, as well as serving as the icon when someone bookmarks your site. You really don’t want to leave this as the default icon, because you’ll miss out on a chance to brand for your site.

Want to save yourself the trouble of creating a favicon for your website? Why not use a tiny version of your Gravatar instead? Check it out:

Using your Gravatar as the favicon of your site is easier than you might think. You can do this in two quick steps.

This code snippet comes to you courtesy of our friends at wp-snippets.com, a fantastic site packed full of quality WordPress hacks.

Step 1: Add the function to your functions.php file.

1
2
3
4
5
function GravatarAsFavicon() {
//We need to establish the hashed value of your email address
    $GetTheHash = md5(strtolower(trim('[email protected]')));
    echo 'http://www.gravatar.com/avatar/' . $GetTheHash . '?s=16';
}

Make sure to replace the email address in the code with your own email address. It must be the email associated with your Gravatar account.

Step 2: Add the link to your header.php file.

1
<link rel="shortcut icon" href="<?php GravatarAsFavicon(); ?>" />

Click save and refresh your site to see your new Gravatar favicon in place.

Using your Gravatar can be very handy if you want to have a favicon for your blog, but you haven’t made a logo for yourself. It’s also much easier than creating a .ico file yourself and uploading it to the correct folders on your site.

Don’t leave your site with the boring default icon for its favicon! Add these quick code snippets and you can have your very own custom favicon in under a minute.

Tags

Comments (4)

Participate