Add Gravatar in WordPress Comments


Posted: 2009-04-24 14:05:11  |   More posts about Text Php WordPress

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.

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

Original comments.php

<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

<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 powered by Disqus

© 2008 - 2012 Ivan Teoh
Under a Creative Commons License except where otherwise noted
Blog RSS Feed | Archives | Tags
Powered by Nikola on DreamHost