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. Is there a Gutenberg Block solution that adds an avatar option in a Post list?

    1. You may want to check out this plugin: https://wordpress.org/plugins/author-avatars/

      Sadly we are not able to confirm if this plugin has this feature for a post list.

  2. D Swarna Prasad Bangre June 3, 2020 at 4:01 am

    I want to know how to get guest author image from the custom field of the post

  3. Hi Kevin,

    Thanks for the post… how to add the author picture and brief info at the end of the post? There are some computer posts that there are different authors, they add their image and short “about me ” at the end of the post which is very cool.

    1. If the theme doesn’t have an author box, you may want to check out: https://wordpress.org/plugins/author-bio-box/

  4. 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

  5. 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/

  6. 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!