add an author image to every post

Today, i wanted to improve and one of the changes i made was to add an author image on every post, so people know instantly whether it’s me or Enda or soemone else posting each individual post. First of all, if you don’t have a gravatar, get one and if you don’t know what they are, read up on them… (if you read blogs, comment on them or own blogs you’ll use them at some stage).

The following snippet of code will display the author’s gravatar….

<?php echo get_avatar( get_the_author_email(), ’30’ ); ?>

If you have author pages / biographies like us, it makes sense to link to them. We created pages called and (they’re also our profile nicknames – sean and enda). The following snippet of code will then grab a link to the author’s nickname…

<?php the_author_link(); ?>

Pull all of that code together and you get this;

<a href=”<?php the_author_link(); ?>” <?php echo get_avatar( get_the_author_email(), ’30’ ); ?></a>

I wanted to display the author image beside the post title so i searched around for where my post title was located in my index.php file…

add author image in wordpress

I added the bit in yellow in, hit save and that was it… bang… a picture of me beside all of my posts on

gravatar for author

Of course that all sounds easy… it was a lot tougher for me to figure out, so this post might just save you hours of head scratching too!

Leave a Reply