How To: Adding the Post Authors Gravatar To Their Individual Posts

One thing I am really excited about is that Gravatars are really starting to gain popularity now that Automattic has purchased and is supporting them. And now that support is built right into WordPress, it opens up a lot of options for WordPress users.

The most common place you’ll find a Gravatar is usually with an individual comment to help comments stand out.  Another place you will sometimes see them is in the sidebar, like we have it setup here at Hack WordPress.   One thing, however, that people are slowly coming around to is using Gravatars with blog posts to identify the author of the post. This is something that is a great idea for a multi-author blog and something I’ve considered doing on this website.

So, how would you go about setting up Gravatars to display with each individual post? Over at ThemeShaper, Ian Stewart recently shared an easy way to do this. You just need the following code:

<?php echo get_avatar( get_the_author_email(), '64' ); ?>

When used, WordPress will match up the e-mail address associated with the post author to determine what Gravatar to use. The 64 is the size (pixels) of the Gravatar.

Great find Ian!

  • Leave a Comment
  • WordPress 2.5+: How To Add Gravatar to Your WordPress Theme

    As we continue to gear up for WordPress 2.5, have you gotten your theme ready for Gravatars? In the past it required plugins, but now WordPress 2.5 has built-in Gravatar support. This means going forward, themes can easily be released with Gravatars built-in to the theme because no plugin will be required.

    So, you’ve got WordPress 2.5 installed and you’re ready to assign Gravatars to your comments? All you need to do is a quick code hack to the comments loop where you want the Gravatar to show up:

    <?php if(function_exists(’get_avatar’)){ echo get_avatar($comment, ‘50’);} ?>

    I encourage everyone to support WordPress by displaying Gravatars on their blogs once you’ve upgraded to WordPress 2.5.

  • Leave a Comment
  • Support WordPress by Displaying Gravatars On Your Blog

    Do you have a Gravatar (Globally Recognized Avatar)? As a loyal fan of the WordPress software that runs each of my weblogs, I feel that it is important to support WordPress in any way that I can. Because this blog focuses on WordPress, that is especially true here.

    You may remember that last October Automattic, the company behind WordPress, purchased Gravatar. In the time since then, they have revamped the infrastructure of Gravatar to drastically speed things up, integrated it into the platform, and then updated the Gravatar WordPress plugin to function better with self-hosted WordPress blogs.

    If you don’t already have a Gravatar, I recommend you first sign up with Gravatar for a free account using whatever e-mail address you normally use to leave comments. Once confirmed, it will then prompt you to upload the avatar you want to use. You’ll need to use the e-mail address used for your Gravatar in the e-mail address field of the comment form (all in lower case) when leaving a comment for the Gravatar to display properly next to each comment.

    Now that Automattic is backing it, and blogs have integrated them, I think that over time Gravatar will continue to grow and the service will continue to get better. It is with that belief that I decided to add individual Gravatars to the comments on this blog (I also revamped the comments section to better support it).

  • Leave a Comment