How to enable Gravatar on WordPress 2.5

So you have heard that WordPress 2.5 has a built-in Gravatar feature? So you have tried enabling it on the Administration Settings (Settings->Discussion->Show Avatars) but no pictures are being displayed at all? 

I was on the same boat like you. Do you know that you still have to insert a code snippet on your comments.php (theme file)? And..No, this is not an April Fools’ Day post :)

How to enable the WordPress 2.5 Built-in Gravatar

First of all, make sure that the feature is enabled on the Administration-Settings-Discussion:

Gravatar Settings on the Administration

Then, go to your Design->Theme Editor and then open/edit your Comments (comments.php) file.

Find this line somewhere on the middle of the codes:

…<?php if ( $comment->comment_author_email == get_the_author_email() ) echo ‘mycomment’; else echo $oddcomment; ?>” id=”comment-<?php comment_ID() ?>”>…
…..
…..<?php comment_text() ?></div>
 

Those are the lines that print the commenting text on the Comments section of your blog. You then have to insert these Gravatar codes around them, like this:

<!– GRAVATAR CODE –>
<table cellpadding=”0″ cellspacing=”1″>
<tr>
<td valign=”top”> 
     <?php echo get_avatar( $comment, $size = ’40’ ); ?>
</td>
<td valign=”top”>
      ……………
      ……………
     <?php if ( $comment->comment_author_email == get_the_author_email() ) echo ‘authorcomment’; else echo ‘thecomment’ ?>” id=”comment-<?php comment_ID() ?>”>
…………
…………<div class=”comment-body”><?php comment_text() ?></div>
</td>
</tr>
</table>
<!– END OF GRAVATAR CODE –> 

So basically put the “wrapping” codes around the codes that start with something + “if($comment->comment_author_email == get_the_author_email()…..” and something + “<?php comment_text()….”

 
The end result will be like:

Gravatar in Comments
       click to enlarge

You can change the avatar size by changing the number 40 in the line
 <?php echo get_avatar( $comment, $size = ‘40‘ ); ?>  to 60,90,120, etc. Try changing the numbers until you’re satisfied with it.

If you know a bit about HTML, then you can always change the codes above to a format that you like. I’m using table to make it neater and make the avatar size to be quite small.

You can always read the official manual to find out more about what you can do with the feature.

 

Screenshots: (Do you know that by typing “SquareBracket”gallery*SquareBracket* on your post, all of the uploaded images & media on the post will appear automatically? Another neat feature of WordPress 2.5!) 

About Michael Aulia

Owner of CravingTech.com, Michael is a tech enthusiast who blends a love for gadgets with a passion for gaming. With insightful articles and professional reviews, he navigates the digital landscape, offering expertise on consumer electronics and gaming trends.

Comments are closed.

Share via
Copy link