Wordpress and Gravatar

As you can see in our blog, I enabled a (hopefully) nice picture of the post authors on the front page. These pictures are called “Gravatar’s“. You can setup a Gravatar and then use the same picture on different sites.

Wordpress has Gravatar support build in since v. 2.5, but only for comments. So if you like to have your Gravatar next to your post you have to make a little (not difficult) hack in your template.

The following informations are a summary from informations you can find on the Net.


 * Since Wordpress 2.8 there is a function called “get_avatar”.This function takes a email address and a integer as argument. The integer is the picture size. To automatically get the email from the author you could use the function “get_the_author_email”


 * To see the Gravatar at your frontpage you have to edit your index.php document of the theme you are using. Paste the following code in the block where you like to see the Gravatar. I placed mine in the entry section.

  


 * To format the picture, mine is float, you have to edit your style.css file of your theme. The class that the picture is using in the code is called “avatar”. You can see it if you display the source code of your page. I also modified the space between the image and the border. Here is the code, paste it at the bottom of your file.

img.avatar { background: #fff; border: 1px solid #000; margin: 2px; padding: 2px; float:left; }

That’s it! Have a lot of fun!