Skip to main content

Ivan Teoh

Something personal yet public

Add Gravatar in WordPress Comments

Recently I start using Gravatar (an abbreviation for globally recognized avatar). It is a free service for providing globally-unique avatars which was created by Tom Werner for blogs and web forums. I want to embedded it in my WordPress 2.7 template. So I try to insert the additional code as below in comments.php and it works. I set my icon size to 50x50. Others might like 40x40. It's depend on personal preference.

49-comments.php (Source)

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

Original comments.php

49-comments-before.php (Source)

<li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>">
<cite><?php comment_author_link() ?></cite> Says:
<?php if ($comment->comment_approved == '0') : ?>
<em>Your comment is awaiting moderation.</em>
<?php endif; ?>
<br />

New comments.php

49-comments-after.php (Source)

<li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>">
<?php if(function_exists('get_avatar')) { echo get_avatar($comment, '50'); } ?>
<cite><?php comment_author_link() ?></cite> Says:
<?php if ($comment->comment_approved == '0') : ?>
<em>Your comment is awaiting moderation.</em>
<?php endif; ?>
<br />

Comments

Comments powered by Disqus