Wordpress, How to insert the Gravatar icon into the comment section
Posted by Daniel - 1,011 Views
When I was blog-walking to several blogs, I saw not all of them but most of them use Gravatar icons to represent the commentator’s email addresses - its cute. Gravatar or Globally Recognized Avatars is basically a 80 x 80 pixel image used to represent your email address. If you do not have any gravatar yet you can got to gravatar website then signup yourself to get it - it’s simple.
OK, now lets find out how you can retrieve the gravatar of each commentator’s email address on your blog. First open your comments.php file - commonly it is placed on your current theme folder - with your text editor.
Find this line of code within the file:
When you already found it, next to do is to replace that line with the following block of code but I think it’s a good idea to backup the original content of your comments.php file since not every theme has as simple code as my current theme.
if (get_comment_type() == ‘comment’) {
echo "<img src=’http://www.gravatar.com/avatar.php?gravatar_id=".md5($comment->comment_author_email)."’ style=’padding-top: 15px’ />";
}
else {
echo "<img src=’http://averagecoder.net/wp-content/uploads/trackback.jpg’ style=’padding-top: 10px’ />";
}
comment_text();
?>
On the above code you can see the get_comment_type() function. It’s a WordPress hook function to get the comment types which only has 3 return values, and they are:
- comment
- trackback
- pingback
I only need to get the Gravatar for normal comment and mark the other comment types (usually a trackback) with the other image so that is why you see the IF statement there to get the intended result.
Cool, basically it’s done and I hope the implementation on your code will be as easy as copy-pasting it. Thanks to ridhocyber for helping me with this one.
Enjoy…
__________________________
The following posts are programmatically considered as related to the current post by YARPP Plugin:
- ContuttoPDF (Wordpress Plugin to convert your Content to PDF)
- Customizing the PDF file created with ContuttoPDF Wordpress Plugin
- Change the WordPress permalink structure to the best format, and yes it’s a little bit scary :D
- Installing Apache, PHP, MySQL and Wordpress on Windows Platform - Part 1
- Installing Apache, PHP, MySQL and Wordpress on Windows Platform - Part 2
Related posts brought to you by Yet Another Related Posts Plugin.
Latest from Programming
- Microsoft Excel Import External Data Problem: When Microsoft Query doesn’t recognize some of your parameters
- SmartImageResizer Plugin, WordPress plugin based on Joe Lencioni’s Smart Image Resizer
- Resize Image or Crop Image with Joe Lencioni’s Smart Image Resizer, WordPress Setup
- Free Softwares to help you learn Regular Expression or to enhance your RegEx skill
- ConsoleProgressBar - Simple Progress Bar Function for your VB.Net Console Application
2 Responses to “Wordpress, How to insert the Gravatar icon into the comment section”
Leave a Reply
Latest Blog Entries
- Sweet Home 3D, a free home design software
- 26x Optical Zoom on a Compact Digital Camera?
- Windows 7 Release Candidate is now available
- Microsoft Excel Import External Data Problem: When Microsoft Query doesn’t recognize some of your parameters
- The Lack of Chances is the Source of Poverty, Can we make a different?
- SmartFTP Client is no longer Free. What would be the best replacement for it?
- Kantaris Media Player, The most suitable Free Media Player on my Audio Environment
Categories
Neighbours and Friends
- Anti Teori
- Busby SEO Test Page
- Deny Sri
- Digital Media Convert
- Freeware Maniac
- Oeroek
- RidhoCyber
- Suraja Web
Comments - Thanks Guys :)
Therese Lachance: Hi, Any idea how to have ContuttoPDF fetch the correct page language?
Marlena Albu: Super Blog, Dude! I am constantly on the watch for new and interesting sites and postings about audio equipment… which is what...
tresloukadu: yo how did u fixed when the tags shows <? and it shows < “& l t ; ” ?? please send me an email.
Sean: This is a great piece of code and thanks for adding the updates. Sean’s last blog post: Not All Text Message Marketing Is Created...
rodhy: Thank for your code, it very usefull for me. best regard.
Most Popular Entries
- Passing arguments to your VB.NET console application
- ConsoleProgressBar - Simple Progress Bar Function for your VB.Net Console Application
- ASCII To PDU Converter (Convert ASCII to PDU and vice versa)
- An example: Using CPort Delphi Component to read data from your cellphone
- Microsoft Excel Import External Data Problem: When Microsoft Query doesn’t recognize some of your parameters
Software Collections
- Sweet Home 3D, a free home design software
- SmartFTP Client is no longer Free. What would be the best replacement for it?
- Kantaris Media Player, The most suitable Free Media Player on my Audio Environment
- TCPView for Windows, Tool to check TCP and UDP Connections on your system
- The Code Snippet Plugin, my favourite syntax highlighter plugin for WordPress
Blogging Related Stuff
- Change the WordPress permalink structure to the best format, and yes it’s a little bit scary :D
- Something is wrong, the Google Search Result from my blog looks bad, don’t laugh please :D
- Several tips to reduce Blog Noise, especially when your blog covers more than one niche
- How to remove your indexed pages or even your entire site from Google and Yahoo!


















February 1st, 2008 at 4:03 pm
This is a test to check the Gravatar Icon…
Cheers :)
March 23rd, 2009 at 4:03 pm
Thanx for the gr8 info.. Trying it on my blog now!
Mahesh’s last blog post: Windows 7 Keyboard Shortcut keys