Add Author Image (Gravatar) to Posts

You may have noticed that I have added an author image each post.  This was done for two reasons:  I like the personal effect and I now have multiple authors.

It’s really quite simple to add the author picture if you’re using WordPress gravatars (which you probably are, even if you don’t know it – I didn’t!).  First, go to Gravatar.com and log in with your WordPress email address and password.  You may have to set up an account if you’ve never been before.  However, you should have a picture.  If you don’t, upload one now.

Now, simply add the code below into one of your templates to get a picture by your posts.  Try making a new <div> in you stylesheet to put this in, say “authorimage”.

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

Since gravatars are squares, the number in the single quotes (in this case, 50) is the number of pixels of how big your image will be. Replace this to fit your page.

Enjoy the post? Encourage me by subscribing to the feed, following me on Twitter, and becoming a fan on Facebook. Cheers!