• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Nile Flores Media

Helping You Rock Out Your Website Like A Rockstar

  • Home
  • About
  • Blog
  • Portfolio
  • Hire Me
  • Resources
  • Contact
  • Blogging
  • WordPress
  • Social Media
  • SEO
  • Web Design
  • News
  • Podcast
You are here: Home » WordPress » Applying Author Gravatar In Post Comments

Applying Author Gravatar In Post Comments

By Nile Flores 11 Comments


Not long ago, Gravatar (globally recognized avatar) was new and shiny, and people were implementing it into their blogs. Gravatar has since become easy to implement and users can simply put in their themes comment.php file:


<?php echo get_avatar( $comment, 32 ); ?>

Where 32 would designate the pixel size of the image that the blog owner wants to allow to be seen on their site.

However, what about those wanting to call the Gravatar to the author of a post? That can of course be done.

What you want to do is retrieve the blog author’s email address and get the avatar if the author has a Gravatar account. You can apply this to your index.php, single.php, comments.php, archive.php where you want the author’s avatar to show on the post.


<?php
$author_email = get_the_author_email();
echo get_avatar($author_email, '32');
?>

Again, 32 is the pixel size to display the avatar. You can adjust this number to what size you wish.

Update: However, although the code has simplified and changed since this post originally was published, most frameworks should already include gravatar. In the case it is not, you should apply the code to your comments.php. However, if your site does, you can go to your WordPress backend at Settings> Discussion, and scroll towards the bottom. It will ask you if you want to allow gravatars to show or not.

You can see more documentation in the WordPress Codex about Using Gravatars. If you do not have a Gravatar account, you should really consider getting one. It is free and much better than the default mystery man that shows up in the comments if a person has no account with Gravatar.


Filed Under: WordPress Tagged With: gravatar, wordpress, wordpress tricks

About Nile Flores

Nile is a 43-year old female from the greater St. Louis (Southern Illinois side) area. Nile is a mother of 1 son. She is also a web designer and developer, a graphic designer, and a public speaker, who exclusively designs and develops using WordPress. She also blogs at GoDaddy's Blog, Verpex Hosting's blog and her very personal sites, Pixelled and Nail Polish Happy.




Related posts:

Edit The Number Of Words For The Excerpt in WordPress How to Change The WordPress Default Avatar Display First WordPress Full Entry and then Following as Excerpts Brand Your WordPress Login Page Without A Plugin How to Display A User Welcome Message In WordPress

Reader Interactions

Comments

  1. vishvast says

    December 15, 2011 at 7:40 pm

    hello
    thnx for the post and the information …..i really do this

    Reply
  2. Jon Anscher says

    December 15, 2011 at 10:06 pm

    Thanks for sharing this. I think Gravatars really add a depth to a conversation in the comments section. I believe there is really something about having a face connected to a name that helps us connect with each other.

    Reply
    • David says

      December 21, 2011 at 7:32 am

      Couldn’t agree more, using gravatar is a good idea as it also helps with recognition for your site.

      Reply
  3. Anok says

    December 16, 2011 at 3:15 am

    Lots and lost are said about WordPress…how can enable Gavatar on blogger? Write some article on blogspot blogger too… plizzzz

    Reply
  4. matt says

    December 16, 2011 at 10:32 am

    Before I use gravatar on my comments but it seems it is affecting the page load time that’s why I remove all the gravatar on my blog.

    Reply
  5. devain richard says

    December 16, 2011 at 6:10 pm

    I use gravatar on my comments but your posting is very useful for antiusers

    Reply
  6. Nirmal Kumar says

    December 16, 2011 at 9:23 pm

    I believe it will increase traffic by encouraging more comments

    Reply
  7. albert says

    December 18, 2011 at 4:57 pm

    I did not know that you could get an account for free.

    Reply
  8. Anonymous says

    December 19, 2011 at 12:02 pm

    thnx for the post and the information …..i really do this, Before I use gravatar on my comments but it seems it is affecting the page load time that’s why I remove all the gravatar on my blog.

    Reply
  9. Loc says

    December 21, 2011 at 11:36 pm

    I believe that having a gravatar adds credibility to your comment post. Most people, if they have their face for everyone to see then they’re not likely going to spam.

    Reply
  10. Robert Koenig says

    January 14, 2013 at 10:10 am

    Very great post Nile! So much information on WordPress and so many possibilities!

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Follow Me On:

  • Facebook
  • Instagram
  • LinkedIn
  • Twitter
  • YouTube

Get The Latest WordPress & Blogging Tips

Sign up for my newsletter, and also get my free ebook on 10 Reasons Why Your Website Isn't Converting, and How to Fix it!




Try to be More Positive on Social Media

Note: You can click on image and view the video in a larger lightbox window.

Footer

The Blog

Lots of free information, tutorials, and more to help you bring your best foot forward with your website.

  • Blogging
  • WordPress
  • Social Media
  • SEO
  • Web Design

Get The Latest WordPress & Blogging Tips

Sign up for my newsletter, and also get my free ebook on 10 Reasons Why Your Website Isn't Converting, and How to Fix it!

Copyright © 2025 · · WordPress