functions.php
file.
function GravatarAsFavicon() { $GetTheHash = md5(strtolower(trim('you@yourdomain.com'))); // your email here echo 'http://www.gravatar.com/avatar/' . $GetTheHash . '?s=16'; // favicon size }
Replace “you@yourdomain.com” with your own email address registered on Gravatar.
This code grabs a 16×16 version of your Gravatar. If you want another size, simply replace ‘?s=16
‘ with your desired size.
Next, add this to your theme’s header.php
file:
<link rel="shortcut icon" href="<?php GravatarAsFavicon(); ?>" />
If you already have a favicon code there, replace it with the above.
With the same function, you can also grab and set the apple touch icon for you site. To do that, first remove ‘?s=16
‘ from the earlier function and then add the following to your theme’s header.php
file:
<link rel="shortcut icon" href="<?php GravatarAsFavicon(); ?>" /> <link rel="apple-touch-icon" href="<?php GravatarAsFavicon(); ?>">
That’s it! Refresh your blog page to see the new favicon.
via Adam Whitcroft