Adding Gravatar on Wordpress 2.5 Theme

I encourage everyone to use Gravatar once you upgraded to wordpress 2.5. The latest WordPress 2.5 has built-in Gravatar support so you don't need to install a Gravatar plugins. All you need to do is open your comments.php and look for comments loop where you want the Gravatar to show up.

My comments loop look like this, it may vary on different theme.

 
<?php foreach ($comments as $comment) : ?> /*start of the loop*/
<li class="<?php echo $oddcomment; ?>"
id="comment-<?php comment_ID() ?>">
 

Code for Gravatar

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

Add the Gravatar code to you comments.php like this

 
<?php foreach ($comments as $comment) : ?>
<li class="<?php echo $oddcomment; ?>"
id="comment-<?php comment_ID() ?>">
<div class="gravatarstyle">
<?php if(function_exists('get_avatar')){
echo get_avatar($comment, 50);
} ?>
</div>
 

Add some style to your gravatar, experiment with spacing or add border

 
.gravatarstyle { float:left; padding-right:10px; }
 

Now your done! See sample comment below.

One Response to “Adding Gravatar on Wordpress 2.5 Theme”

  1. my avatar :D

Leave a Reply