It's April 11th, and it's a Saturday. That means it's time for another quick code snippet from ForTheLose.org. Today I'll be showing you guys how to display your Gravatar in the author's post on a WordPress blog.
Firstly, today's quick snippet is credited to an article I read on WPRecipes.com when I was looking up how to do this myself a while back. So a big thanks to them.
In most cases, the commentator's Gravatar is fetched from the Gravatar servers by looking at the email the commentator used. So when you think about it, all we need to do is grab the post-author's email and tell Gravatar to display the correct image that corresponds to that email. This is accomplished very simply using the get_the_author_email() function, which fetches the email the author has in his WordPress profile.
<?php $author_email = get_the_author_email(); echo get_avatar($author_email, '98'); ?>
And that's it. Just paste that bad boy wherever you want the Gravatar to be displayed and you're done.
If you liked this post, stay updated. Follow me on Twitter or subscribe to our RSS Feed via email.
Post Tags: Saturday Snippets


Hot damn.