X

How to Display Author Avatar Within Posts or Pages

Snippets by IsItWP

Are you looking for a way to display the current authors avatar? While there’s probably a plugin for this, we have created a quick code snippet that you can use to display the current authors avatar in WordPress.

Instructions:

All you have to do is add this code to your theme’s single.php file:

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

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 10 best WordPress plugins for web developers and how to secure your WordPress forms with password protection.

Comments  Leave a Reply

  1. venkatesh sakthivel May 12, 2014 at 7:44 am

    hi Kevin, how to replace featured image of a post by author avatar. plz help me

  2. It have a way to catch this src link to put in my configurations? like <img src="/images/fake-avatar.jpg” title=”Richard Dawkings” class=”fl gravatar-author”> I’m won’t like a wordpress config to  gravatar author post used, I wanna use my way.

    1.  you can use this snippet to set a default gravatar image,
      http://wpsnipp.com/index.php/comment/custom-default-gravatar-image/

  3. sorry to bother you again … but it doesn’t do what i wanted than anyway mate …. cheers

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!