Not long ago, Gravatar (globally recognized avatar) was new and shiny, and people were implementing it into their blogs. Gravatar has since become easy to implement and users can simply put in their themes comment.php file:
<?php echo get_avatar( $comment, 32 ); ?>
Where 32 would designate the pixel size of the image that the blog owner wants to allow to be seen on their site.
However, what about those wanting to call the Gravatar to the author of a post? That can of course be done.
What you want to do is retrieve the blog author’s email address and get the avatar if the author has a Gravatar account. You can apply this to your index.php, single.php, comments.php, archive.php where you want the author’s avatar to show on the post.
<?php
$author_email = get_the_author_email();
echo get_avatar($author_email, '32');
?>
Again, 32 is the pixel size to display the avatar. You can adjust this number to what size you wish.
Update: However, although the code has simplified and changed since this post originally was published, most frameworks should already include gravatar. In the case it is not, you should apply the code to your comments.php. However, if your site does, you can go to your WordPress backend at Settings> Discussion, and scroll towards the bottom. It will ask you if you want to allow gravatars to show or not.
You can see more documentation in the WordPress Codex about Using Gravatars. If you do not have a Gravatar account, you should really consider getting one. It is free and much better than the default mystery man that shows up in the comments if a person has no account with Gravatar.
vishvast says
hello
thnx for the post and the information …..i really do this
Jon Anscher says
Thanks for sharing this. I think Gravatars really add a depth to a conversation in the comments section. I believe there is really something about having a face connected to a name that helps us connect with each other.
David says
Couldn’t agree more, using gravatar is a good idea as it also helps with recognition for your site.
Anok says
Lots and lost are said about WordPress…how can enable Gavatar on blogger? Write some article on blogspot blogger too… plizzzz
matt says
Before I use gravatar on my comments but it seems it is affecting the page load time that’s why I remove all the gravatar on my blog.
devain richard says
I use gravatar on my comments but your posting is very useful for antiusers
Nirmal Kumar says
I believe it will increase traffic by encouraging more comments
albert says
I did not know that you could get an account for free.
Anonymous says
thnx for the post and the information …..i really do this, Before I use gravatar on my comments but it seems it is affecting the page load time that’s why I remove all the gravatar on my blog.
Loc says
I believe that having a gravatar adds credibility to your comment post. Most people, if they have their face for everyone to see then they’re not likely going to spam.
Robert Koenig says
Very great post Nile! So much information on WordPress and so many possibilities!