How to show an author’s avatar within WordPress

If you’d like to show the author’s avatar within a WordPress post, we’ll show you how in this article. While the functionality is not built into WordPress (version 3.2.1 as of this writing), you can surprisingly accomplish this task with just one line of code.

In this article, we’ll update the top part of the post that says “Posted on” so that it shows the author’s avatar. Refer to the screenshots below to see the results.

In this article, you will learn how to show an author’s avatar within WordPress.

Showing an Author’s Avatar in WordPress

  1. Log into your WordPress Dashboard
  2. In the left menu, under “Appearance”, click “Editor”
  3. On the “Editor” page, find and click “content.php” in the list of files on the right of the page
  4. Find this section of code:

    … and replace it with this:

That’s it, you’re done! In this tutorial we placed the author’s avatar at the top of the post (for the homepage). If you’d like show the author’s avatar from anywhere else within the post (or on other pages), simply use the following code:

   <? echo get_avatar( get_the_author_meta('user_email'), $size = '50'); ?>

Congratulations, now you know how to show an author’s avatar within WordPress!

19 thoughts on “How to show an author’s avatar within WordPress

  1. Hi there, your code worked on my site, but how do I get it to display on older posts please? It only displays on the current post.
    regards Kate

  2. Working good, but if i add <img> tag of html and echo it in src its not working so how can i add css to it to display a round image instead of sqare 

    1. As I understand, Gravatars are by default square. You maybe able to find a plugin that allows you to customize the Gravatar shape.

  3. Hi,

    By using the above code, I’m getting only thumbnails.
    Any way to retrieve the bigger images? Please help.

  4. Also after displaying user avatars within wordpress you can set so many different effects to avatars using a new useful free plugin Avatars Effects ( This plugin will help you set beautiful and interesting effects on avatars without writing any css code..

  5. Great Great Great. i was looking for this fro last 12 hours with lot of google search and headache but didt found solutions, and your post worked like a magic for me


    Bundle of thanks again dude 🙂

  6. You wouldn’t necessarily have to make a child theme or re-do the changes in the theme. You could set up a plugin that filters the_title or the_content and returns the avatar with it.

    1. Hello Megan,

      Thanks for your comment! We probably need to update this article as the handling of Avatars has definitely changed in WordPress with the latest versions. Thanks for your input!

      If you have any further questions, please let us know.

      Kindest regards,
      Arnel C.

  7. What happens when there is an update to WordPress. THe user will have to manually re-insert the changes again.

    1. Hello Zion,

      I would think so. Any time a core file is modified it should be expected that it will need to be redone after an update.

      Kindest Regards,
      Scott M

Was this article helpful? Join the conversation!

Web Hosting Cyber Week Sale
Hurry! These Deals Won't Last Long