Gravatar as Favicon

If you’ve seen how Tumblr uses the blog author’s Gravatar as the blog favicon and want to replicate that in WordPress, simply paste this into your functions.php file.

And then, in the <head> of your header.php, paste the following:

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

If you want to use the same function to grab the apple-touch-icon all you need to do is omit the ‘?s=16’, and add in another link in your <head>:

&lt;link rel="shortcut icon" href="<?php GravatarAsFavicon(); ?>" /><br />
&lt;link rel="apple-touch-icon" href="<?php GravatarAsFavicon(); ?>">

Code Snippet:

<?php
function GravatarAsFavicon() {
	//We need to establish the hashed value of your email address
	$GetTheHash = md5(strtolower(trim('you@yourdomain.com')));
	echo 'http://www.gravatar.com/avatar/' . $GetTheHash . '?s=16';
}
?>

Posted in Pure hacks