How To Add Gravatars For The Post Author in WordPress

Now that Gravatar support is part of the WordPress core adding them into your WordPress theme is easy. Adding them to your comments has been documented. How about adding them to your post titles to highlight the comment author? Within the loop? That’s fairly easy too. Here’s the code:

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

Pretty simple, huh? get_the_author_email outputs the post author’s email and the “80″ is the size of the avatar image in pixels (you can change that). How this will look depends on how you use it; where you put it in the theme (it has to be in the loop!) and how you style it.

Want an example? I had to figure this out for an upcoming project so…

Author Gravatar Example

Look at that frighteningly intense young man there in black and white. Good grief, it’s me! The author of the post! The code, it works! It works!

Ahem. Excuse me. I get a little excited about these things. Good luck using it in your own theme!

By the way, did you know WordPress has built in email protection from spam bots (read Disguising Your Email)? I didn’t. Neat.

162 thoughts on “How To Add Gravatars For The Post Author in WordPress

  1. Pingback: 40+ Most Wanted Wordpress Tricks and Hacks | Quest For News, A TUTORIAL Base

  2. Pingback: | Mellowish

  3. Pingback: 40+ Most Wanted Wordpress Tricks and Hacks | Overflowed Media

  4. Pingback: 40+最值得应用的WordPress技巧和工具 « 爱牛牛玩具总动员

  5. Pingback: Top 40+ most wanted wordpress tips and tricks | Tomislav Mihajlovic (Toma) - Toma2U.com

  6. Pingback: 草根评论 » 40+ Wordpress中的Tricks and Hacks技术

  7. Pingback: Unlimited New Useful Wordpress Tips,Tricks & Hacks - Themeflash : One Stop For All Your Web Resources

  8. Pingback: D.K推荐41个最有用的WordPress技巧 | iOver

  9. Pingback: US Want - Your Blogs, Social Network, Search Engine for Drivers, UserGuide, Vids, Images, Tutorials

  10. Pingback: 10 Ways to Customize and Personalize your Wordpress Blog | Pro Blog Design

  11. Pingback: wordpress düzenleme ve kişiselleştirme yolları « Bay Bedava – Netten Başlıklar

  12. Pingback: wordpress düzenleme ve kişiselleştirme yolları | Teknoloji Sokağı

  13. Pingback: 40+ Most Wanted Wordpress Tricks and Hacks | My Tech way

  14. Thank you very much for this useful information.
    I created a plugin recently to display “about the author” box above the posts and I used gravatar in it.
    Thanks again and take a look at the plugin.

  15. Pingback: 41 Most Wanted Wordpress Tricks and Hacks | eBookTM | Download ebook, Jetaudio skin, Games

  16. Pingback: Most Wanted 40+ Tips and Hacks For Wordpress | oOrch Blog

  17. Pingback: 40+ Most Wanted Wordpress Tricks and Hacks « Los temas del Pelado

  18. Pingback: 40 consejos y trucos para Wordpress « Los temas del Pelado

  19. Pingback: 40+ Most Wanted Wordpress Tricks and Hacks | 9Tricks.Com - Tips - Tricks - Tutorials

  20. Pingback: 40+ Most Wanted Wordpress Tricks and Hacks - Wordpress Releases

  21. Pingback: 10 Ways to Customize and Personalize your Wordpress Blog | SEO & Web Design

  22. Pingback: 10 Ways to Customize and Personalize your Wordpress Blog | SEO & Web Design

  23. Pingback: NamrouD | Upgrade Your Mind ! » 40+ Most Wanted Wordpress Tricks and Hacks

  24. Hi i just put the code into the single.php archive from my theme. I put it in the code of the title at the beggining of the title and reduced the size from 80 to 50 and now it looks great.

    A great simple code!!

    Thanks

  25. Pingback: 40+ Most Wanted Wordpress Tricks and Hacks | GREYBLOGS

  26. Pingback: Online live » Blog Archive » 40+ Most Wanted Wordpress Tricks and Hacks

  27. Pingback: 30 Amazing Wordpress Hacks, Tricks, Scripts « Desi Garmi: Malayalam Masti…!

  28. Pingback: Wordpress Hacks | DaveDesign.us

  29. Pingback: FAQPAL Blog

  30. Pingback: Mas de 40 Trucos para tu Wordpress | trukos!

  31. Pingback: BLOG { jörg steinhauer } » Gods of GFX #3 – Web

  32. Pingback: 35 WordPress Tips and Tricks You Must Know | SmashingHub

  33. Pingback: 35 WordPress Tips and Tricks You Must Know « Design Works

  34. Pingback: 23 articles and resources to improve your Wordpress life! | JortK.nl

  35. Pingback: 30个优秀的Wordpress技巧为您打造强大的博客 – 【大嘴的窝棚】

  36. Pingback: 40+ Most Wanted Wordpress Tricks and Hacks « Agencija 027 S.N.O.B.

  37. Excellent! I wanted the pic in the bottom under the content (which this works great for, by the way), but now I think I might like to have it up there at the top. Thanks for the help.

  38. Pingback: 30 Wordpress Hacks You Gotta Have | Altered Advice

  39. Pingback: 40+最值得应用的WordPress技巧和工具 | 屁民球球的设计小屋

  40. Pingback: 41个最有用的WordPress技巧 | 心绪视觉团队

Comments are closed.