Title: Limiting Comments
Last modified: August 19, 2016

---

# Limiting Comments

 *  [Jess](https://wordpress.org/support/users/jessn/)
 * (@jessn)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/limiting-comments-1/)
 * Weird thing I’m trying to do: I’m modifying the comments form so that it only
   displays the 13 most recent comments, using the code from here: [http://www.jayminkapish.com/2008/06/13/comments-pagination-wordpress/](http://www.jayminkapish.com/2008/06/13/comments-pagination-wordpress/)
 * That works great. However I don’t want it to page. Whenever someone posts a new
   comment it displays at the bottom of the list, and I want the oldest at the top
   to drop off.
 * Possible? Does anyone know how to do that?

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

 *  Thread Starter [Jess](https://wordpress.org/support/users/jessn/)
 * (@jessn)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/limiting-comments-1/#post-1613277)
 * Ah. So what I want to do is display the last page of comments fist by default.
   But I only want to do that for this particular page (I’m using a if is_page statement
   in the comments form). Anyone know if it’s possible to tell the comments to display
   the last page first in comments.php?
 *  Thread Starter [Jess](https://wordpress.org/support/users/jessn/)
 * (@jessn)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/limiting-comments-1/#post-1613358)
 * So nevermind, I went about it a different way. Perhaps this will help someone
   else in the future, who knows. I just queried the database to pull up posts for
   that particular page ID:
 *     ```
       <?php
       global $wpdb;
   
       	$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID,
       	comment_post_ID, comment_author, comment_date_gmt, comment_approved,
       	comment_type,comment_author_url,
       	SUBSTRING(comment_content,1,50) AS com_excerpt
       	FROM $wpdb->comments
       	LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =
       	$wpdb->posts.ID)
       	WHERE comment_approved = '1' AND comment_type = '' AND
       	post_password = '' AND comment_post_ID = 90
       	ORDER BY comment_date_gmt DESC LIMIT 13";
   
       	$comments = $wpdb->get_results($sql);
       $comments = array_reverse($comments);
       	$output = $pre_HTML;
       	$output .= "\n
       <ul class='sonnet-lines'>";
   
       	foreach ($comments as $comment) {
       	$output .= "\n
       <li>"."
       <div>" . strip_tags($comment->com_excerpt)
       	."</div>
   
       </a></li>
   
       ";
       	}
   
       	$output .= "\n</ul>
   
       ";
       	$output .= $post_HTML;
   
       echo $output; ?>
       ```
   

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

The topic ‘Limiting Comments’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 1 participant
 * Last reply from: [Jess](https://wordpress.org/support/users/jessn/)
 * Last activity: [15 years, 10 months ago](https://wordpress.org/support/topic/limiting-comments-1/#post-1613358)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
