Gravatars: Revisted

Filed Under: WordPress

Back in April I showed you how to add Gravatar support to your WordPress blog (see Gravatars) but after re-reading that article a few times I came to the realization that perhaps it was a bit too difficult for novice users to grasp. After further research and much trial and error I’ll now present what I feel is a much more simplified way to accomplish this. Keep in mind that this only applies to themes that don’t have the functionality already built-in. Obvious I know but worth mentioning nevertheless.

Step 1: Open comments.php in your favourite plain text editor (notepad will work just fine) and look for the following line …

<?php comment_text() ?>

… and replace it with this …

<div class="gravatar">
<?php if (get_bloginfo('version')>=2.5)
echo get_avatar( $comment->comment_author_email, $size = '50', $comment->comment_author_link);?>
<?php comment_text() ?>
</div>
<br clear="all" />

Step 2: Now we need to add the styling for your new Gravatars in the style sheet. Open style.css in your favourite plain text editor and add the following …

.gravatar {margin-top:20px;}
.avatar {float:left; border:1px solid #BBBBBB; padding:3px; margin-right:5px; margin-bottom:5px;}

Step 3: Upload the modified files using your favourite FTP client. (I always recommend working with files offline and uploading rather than using the built-in theme editor.)

Of course the styling attributes you use may vary from theme to theme but this is a starting point. Experiment away.

 

2 Comments so far. Click here to join the discussion!

  1. Is

    I wish I could add a gravatar template tag to my site :(


  2. I hear through the grapevine Google will be offering Gravatar support for Blogspot in the not-so-distant future.


Reply to “Gravatars: Revisted”

Please note: Comment moderation is in effect. It may take some time for your comment to appear. There is no need to resubmit it.

Off-topic comments, personal attacks, obvious spam and support requests will likely not make it out of moderation. This site does not necessarily endorse or agree with comments left here.

 

Back On The Air!

Live weekly show featuring the movers and shakers of WordPress.

  • WordPress

Just Say No!

To themes using obfuscated code.

  • Say No to Obfuscated Code!

Powered By ...

Is there anything else? Anil...?

  • Powered by WordPress!