As we continue to gear up for WordPress 2.5, have you gotten your theme ready for Gravatars? In the past it required plugins, but now WordPress 2.5 has built-in Gravatar support. This means going forward, themes can easily be released with Gravatars built-in to the theme because no plugin will be required.

So, you’ve got WordPress 2.5 installed and you’re ready to assign Gravatars to your comments? All you need to do is a quick code hack to the comments loop where you want the Gravatar to show up:

<?php if(function_exists(’get_avatar’)){ echo get_avatar($comment, ‘50’);} ?>

I encourage everyone to support WordPress by displaying Gravatars on their blogs once you’ve upgraded to WordPress 2.5.

Kyle Eslick is WordPress enthusiast who took his passion for WordPress to the next level in 2007 by launching WPHacks.com as a place to share hacks, tutorials, etc. Connect with Kyle on Twitter or Google+!

  • bardo

    Thanks for that.
    What about placing it anywhere outside of the comments loop? I’d like to put it on my index page, in a header, close to the navigation menu, for example..

  • http://www.macnightowl.com Gene Steinberg

    Since you asked, I have modified by theme to include them at:

    http://www.macnightowl.com

    Peace,
    Gene Steinberg

  • http://kyleeslick.com Kyle Eslick

    @ Bardo – You should be able to use the code wherever you want to display a Gravatar, as long as there is an e-mail address assigned to the post/sidebar, etc. (Like an About Author section, etc.)

    @ Gene – I checked it out and it looks great!

  • http://www.macnightowl.com Gene Steinberg

    Thank you. It took all of a minute or so add the code to each of my comments files (the site is made up of two integrated blog installations). And I don’t speak PHP.

    Peace,
    Gene

  • Pingback: WordPress Wednesday News: WordPress 2.5 Due Any Day, Beta 2 Released, Many Plugins Updated, WordCamp Dallas This Weekend, WordCamp UK Suggested, and More : The Blog Herald

  • Pingback: WordPress 2.5 Release Candidate 2 | Vi?t Tutorial [Viettut.info]

  • wOw!bloggiNE

    I’m Vietnamese. I don’t speak well English.
    Can you help me ? I don’t know.
    Where can i place code ? in comment.php? i want it’s showed in right comment same you
    and code of recent comment in your sidebar is great. Can you share it ?

  • http://kyleeslick.com Kyle Eslick

    @ Wow – Yes, place it within your comments.php file wherever you want it to display. If you dig through the code, you should see some things you recognize from your comment layout, so that is an easy way to figure out where to place the code. You may have to experiment until you’ve got it in the right spot.

  • Pingback: Random WordPress 2.5 How-To’s :: WPLover

  • http://alove4horses.com Joni Solis

    Sounds so easy to do, but after 30 minutes of trying I still couldn’t get an gravatar image to show up in my blog’s comments. I tried putting the code from this post in a whole lot of different spots in the comments.php file but all it did was cause my post to show no comments at all and not load right.

    Can someone pin point exactly where in the comments.php file this code goes? I have the WordPress Theme Almost Spring.

    By the way, what WP plugin are you using for your email notify of comments. Thanks!

  • http://www.jauhari.net/ Jauhari

    Let’s me tested and give you a feedback

  • http://alove4horses.com Joni Solis

    Is there a WordPress Plugin that put this text:

    [Want automatic updates? Subscribe to our RSS feed or Get E-mail Updates Automatically!]

    At the bottom of each post? What is the name and the URL where I can get it and does it work with WP2.5?

    Thanks!

  • http://alove4horses.com Joni Solis

    For anyone having trouble (like me) adding gravatar images to their comments. I went and installed the WordPress plugin…

    Easy Gravatars
    http://wordpress.org/extend/plugins/easygravatars/installation/

    Easy Gravatars 1.2
    http://dougal.gunters.org/

    Add Gravatars to your comments, without requiring any modifications to your theme files. Just activate, and you’re done! By Dougal Campbell.
    —-
    Now I have gravatars images, yea!

  • Pingback: Add Gravatar Support to Your WordPress Comments | Theme Lab

  • MhawSayar

    It’s one of the great function of WP 2.5. I love it too and thanks for sharing knowledges! :)

  • bienB

    Gracias por la informacion, pero ¿como puedo crear un avatar?

  • http://macamour.com/blog/ HEdi

    It shows me an error when I insert that line of code you gave:

    Parse error: syntax error, unexpected ‘)’ in /home/macamour…./comments.php on line 98

  • Pingback: Memasukkan Gravatar pada comments | Mochammad Kurniawan

  • http://hayespotter.co.nr Hayes Potter

    I uploaded a picture of me to my wordpress.com account, that I have my blog registered under. My wp.com profile has the same email address as the one I use everywhere. But my gravatar will never show up on any blog. My username for wp.com is hayesp could that effect anything?

  • http://davezan.com David

    Whew, been trying to find out how to do this. Gave it a try, and…well…it works. :)

    Definitely adding this site to my WordPress-related bookmarks. I’ll be sure to post questions or so if the need arises.

  • http://www.dazzlindonna.com/blog/ DazzlinDonna

    There is an error in that code. The ? after the 50 should be a single quote, not a ?.

  • http://kyleeslick.com Kyle Eslick

    @ Dazz – Thanks. I have corrected the code in the above post. Hopefully that will fix any of the errors listed above.

    @ Joni – That is the Subscribe to Comments plugin. Do a Google search and it should be the first one that shows up. The text I use at the bottom of each post is not a plugin, it is just basic HTML with a link to both subscription options. You can add it just below the content in your single page file.

    @ Hayes – You need to sign up at Gravatar.com to get your Gravatar.

  • teguh

    Thanks for your post..it’s work, thanks

  • http://www.seosoeasy.com kamal

    This is just awesome.You helped me a lot!Thanks.

  • http://mohamedaslam.com Sri Lanka best SEO

    Thank you very much for the awesome post. It’s really works!

  • khan

    i have tried several times but it is not workin…

  • http://hygen.net/blog Dan

    Yo can easily put Gravatars anywhere, I use them in a drop-down nav menu – tutorial here – http://hygen.net/blog/?p=427

  • Alex

    Hey, thanks for the code but a quick heads up.

    The code snippet above has curly quotes around ‘get_avatar’ and ’50′ which will break it for copy and pasters.

  • Rollins

    Nice.

  • http://www.migratedesign.com Laurent Jouvin

    Thanks! I’ll have to try this asap.

  • http://ecohr.wordpress.com Msuvain

    Will the 2.5 function automatically hash the lowercase version of the email address? This seems to be a persistent issue, with users leaving mixed-case version of their email address with their comments.

  • J. Guimarães

    I like this idea.

  • http://www.joseguimaraes.com/ J. Guimarães

    Already installed on my blog.
    I really enjoyed.