Title: List recent comments
Last modified: August 19, 2016

---

# List recent comments

 *  Resolved [junihh](https://wordpress.org/support/users/junihh/)
 * (@junihh)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/list-recent-comments/)
 * I’m working on my own first theme designe for my blog. Because i don’t know how
   to make widgets i’m coding the sidebar manually. Now i need to list the recent
   comments on the sidebar but not using a widget.
 * There’s a way to list the recent comments without a widget ???

Viewing 12 replies - 1 through 12 (of 12 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/list-recent-comments/#post-978927)
 * Just ripped this out of wp-includes/widgets.php
 *     ```
       <?php
       $number=5; // number of recent comments desired
       $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number");
       ?>
       <ul id="recentcomments">
       <h2>Recent Comments</h2>
       <?php
       if ( $comments ) : foreach ( (array) $comments as $comment) :
       echo  '<li class="recentcomments">' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_comment_link($comment->comment_ID) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
       endforeach; endif;?></ul>
       ```
   
 * There’s probably a plugin (without a widget) that could also do this.
 *  Thread Starter [junihh](https://wordpress.org/support/users/junihh/)
 * (@junihh)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/list-recent-comments/#post-978946)
 * Hey, thanks for your help, that working for me. [This is what i did](http://macoreo.com/)
   with that code (in the sidebar > Comentarios tab box).
 * Thanks again for your help.
 *  Thread Starter [junihh](https://wordpress.org/support/users/junihh/)
 * (@junihh)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/list-recent-comments/#post-978963)
 * [@michaelh](https://wordpress.org/support/users/michaelh/), sorry that i complicated
   a bit more but is there a way to show only the comments from my visitors and 
   exclude my own comments ???
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/list-recent-comments/#post-978964)
 * set the WHERE clause to something like this:
 * `WHERE comment_approved = '1' AND user_id != '5'`
 * Of course you need to use your user id in place of the 5.
 *  Thread Starter [junihh](https://wordpress.org/support/users/junihh/)
 * (@junihh)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/list-recent-comments/#post-978972)
 * Great, that working for me. Thanks again.
 *  [Snaggletooth](https://wordpress.org/support/users/snaggletooth/)
 * (@snaggletooth)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/list-recent-comments/#post-978990)
 * Aha! (light turns on) very helpful indeed.
    Used it to list author comments on
   the profile page (author.php) by adding ..`AND user_id='".$curauth->ID."'`.. 
   to the db query.
 *  [eac18509](https://wordpress.org/support/users/eac18509/)
 * (@eac18509)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/list-recent-comments/#post-979000)
 * [@snaggletooth](https://wordpress.org/support/users/snaggletooth/) -I have been
   trying to figure that out for weeks to show just comments from the author on 
   profile page.
 * Could you please share the code. I don’t understand where to put the little snippet
   of code you referenced.
 * Thanks in advance.
 *  [cornhustlah](https://wordpress.org/support/users/cornhustlah/)
 * (@cornhustlah)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/list-recent-comments/#post-979027)
 * hi.
    so is there a way to add to this snippet of code so that the actual comments
   are shown as well? i’d like very much to show the comment (or at least part of
   it), the user’s screen name, the user’s gravatar and the article (post) name.
 * anyone got a some info or a lead to follow for this?
 *  [matstillo](https://wordpress.org/support/users/matstillo/)
 * (@matstillo)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/list-recent-comments/#post-979050)
 * Just adding to cornhustlah’s request for implementing a snippet of the excerpt
   as well!
 * I was thinking I could do something with `<?php comment_excerpt(); ?>`
    but it
   is not as straightforward as I hoped.
 * Did anybody find a plugin that doesn’t use a widget?
 *  [mores](https://wordpress.org/support/users/mores/)
 * (@mores)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/list-recent-comments/#post-979052)
 *     ```
       $comment_content = strip_tags($comment->comment_content);
       $comment_content = stripslashes($comment_content);
       echo $comment_content;
       ```
   
 * apply where needed 🙂
 *  [Aldi](https://wordpress.org/support/users/bedex78/)
 * (@bedex78)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/list-recent-comments/#post-979091)
 * How do you limit the number of characters (or lines, maybe) for the comments?
 *  [TataVostru](https://wordpress.org/support/users/tatavostru/)
 * (@tatavostru)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/list-recent-comments/#post-979109)
 * wath is the code for only display the title post , that was commented … i do 
   not want to display who posted and site

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘List recent comments’ is closed to new replies.

## Tags

 * [Comments](https://wordpress.org/support/topic-tag/comments/)
 * [list](https://wordpress.org/support/topic-tag/list/)
 * [meh_code](https://wordpress.org/support/topic-tag/meh_code/)
 * [recent](https://wordpress.org/support/topic-tag/recent/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 12 replies
 * 9 participants
 * Last reply from: [TataVostru](https://wordpress.org/support/users/tatavostru/)
 * Last activity: [16 years, 6 months ago](https://wordpress.org/support/topic/list-recent-comments/#post-979109)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
