How to Display Recent Comment with Gravatar – No Plugin

Posted By Peach on February 14th, 2011

WordPress has already provided you the Recent Comment by widget setting but it has no picture gravatar. Today I’m working on it, this tutorial will show you all what I’ve done.

config the avatar type
1. Browse to you theme folder. Open “Sidebar.php” then put this code.

<div>
<h2>Recent Comments</h2>
<ul>
  <ul><!--?php <br ?--> $comments = get_comments('number=5');</ul>
</ul>
<ul>
  <ul>foreach($comments as $comm) :$url = '</ul>
</ul>

<a title="'.$comm-&gt;comment_author .' | '.get_the_title($comm-&gt;comment_post_ID).'" href="'. get_permalink($comm-&gt;comment_post_ID).'#comment-'.$comm-&gt;comment_ID .'">' . $comm-&gt;comment_author . '</a>

<ul>
  <ul>';</ul>
</ul>
<ul>
  <ul>?&gt;
     <li><!--?php echo get_avatar($comm--->comment_author_email, 30); ?&gt;</li>
  </ul>
</ul>

</div>

2. Open “style.css” then put the following selector to manage displaying style.

<div>
<h2>Recent Comments</h2>
<ul>
  <?php
  $comments = get_comments('number=5');
  foreach($comments as $comm) :$url = '<a href="'. get_permalink($comm->comment_post_ID).'#comment-'.$comm->comment_ID .'" title="'.$comm->comment_author .' | '.get_the_title($comm->comment_post_ID).'">' . $comm->comment_author . '</a>';
  ?>

  <li>
     <?php echo get_avatar($comm->comment_author_email, 30); ?>
     <strong><?php echo $url; ?></strong>
     <p><?php echo $comm->comment_content; ?></p>
  </li>

  <?php  endforeach;  ?>
</ul>
</div>

3. Upload “sidebar.php” and “style.css” to your hosting. Go through Admin page > Settings > Discussion then select your prefer type of Avatar. Finished, here is what I’ve got.
Display recent comment with Gravatar

Tags: , ,

  • http://www.senukeseosoftware.com/category/seo-software-videos/ Best SEO Software

    Really great subject!

  • http://www.senukeseosoftware.com/category/seo-software-faqs/ The Best SEO Software

    Thanks for these more forward-thinking ideas.

  • http://asicssneakerblog.brokers.ru/ Shanita

    Just where is the facebook like button ?

  • http://www.nexttravelvacation.com/ Gabrielle

    Terrific, that’s precisely what I was shooting for! Your article just spared me alot of digging around

    I’ll make certain to put this in good use!

  • http://www.grgwebsites.com design website and buidl website

    An interesting discussion is worth comment. I think that you should write more on this topic, it might not be a taboo subject but generally people are not enough to speak on such topics. To the next. Cheers

  • http://chadlotario.tumblr.com/ Internet marketing tools

    Please, can you PM me and tell me few more thinks about this, I am really fan of your blog

  • http://google.com WillSmith

    ZPqbii Hi! I’m just wondering if i can get in touch with you, since you have amazing content, and i’m thinking of running a couple co- projects! email me pls

  • http://www.mmpersonalloans.com/ Dopalacze

    Date Hello, I have browsed most of your posts. This post is probably where I got the most useful information for my research. Thanks for posting, maybe we can see more on this. Are you aware of any other websites on this subject

  • http://www.mmpersonalloans.com/ Dopalacze

    I fully agree with author opinion.

  • http://www.charteryachtcaribbean.com Rental Yacht

    I love the blog site layout ! How did you make it!? It is very cool!

  • http://www.charteryachtcaribbean.com charter yacht caribbean

    A cool post right there mate ! Cheers for the post .

  • http://www.tonecor.com barricas

    No specific criteria and I don’t take it too seriously. I just score em’ like the magazines do.

  • binh nguyen

     Please, translate code from WordPress to Blogger! sent rerult to mail: vietlao2003@gmail.com

  • http://1freecougardating.com free cougar dating

    Great thanks for the share , This what I;m looking for my blog !!