Installing Gravatar support on your blog

Last month I posted about how you should have a gravatar, a gravatar is an avatar system which will display a chosen avatar whenever you post a comment on a blog with gravatar support. So if you are a blog owner and would like to add support for these avatars then just follow this simple advice.

To begin with you will need to find your ‘comments’ template, open that up and then search for the following line of code:
<li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">

Once found add the following code after the line:
<?php if(!empty($comment -> comment_author_email)) {
$md5 = md5($comment -> comment_author_email);
$default = urlencode('DEFAULT PATH');
echo "<img src='$md5&size=20&default=$default' alt='' />";

Finally, change the DEFAULT PATH in the code above to the location of a default avatar that will be used if the commenter has not defined (signed up for) a gravatar. Save your file, and now you should have gravatar support without the need of any plugin.