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 50×50. Others might like 40×40. It’s depend on personal preference.

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

Original comments.php

40
41
42
43
44
45
  1. <li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>">
  2. <cite><?php comment_author_link() ?></cite> Says:
  3. <?php if ($comment->comment_approved == '0') : ?>
  4. <em>Your comment is awaiting moderation.</em>
  5. <?php endif; ?>
  6. <br />

New comments.php

40
41
42
43
44
45
46
  1. <li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>">
  2. <?php if(function_exists('get_avatar')) { echo get_avatar($comment, '50'); } ?>
  3. <cite><?php comment_author_link() ?></cite> Says:
  4. <?php if ($comment->comment_approved == '0') : ?>
  5. <em>Your comment is awaiting moderation.</em>
  6. <?php endif; ?>
  7. <br />

References

No Comments

No comments yet.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">