• Posted: 2011-10-17
  • Author: Adam Whitcroft
  • Tags:

Gravatar as Favicon

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
<?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';
}
?>

Instructions:

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:

<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>:

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

Related links:
http://gravatar.com/
Share this snippet

If you like this snippet, share it with friends!