WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want list the popular posts.popular post is defined by number of comments.If number of comment is high it will consider as popular.

How can i do this !

share|improve this question
up vote 2 down vote accepted

You can easily sort by native post fields, so try something like this:

$posts  = get_posts( array(
                 'numberposts' => 10,
                 'orderby' => 'comment_count',
                 ) );
share|improve this answer
It works fine thanks – Gowri Jul 5 '11 at 14:11

Copy paste the following code, where you want to display the popular posts

$popular = $wpdb->get_results("SELECT id, post_title, comment_count FROM {$wpdb->prefix}posts WHERE post_type='post' ORDER BY comment_count DESC LIMIT 10");

foreach($popular as $posts) : ?>
<li> <?php echo $posts->post_title; ?> </li>
<?php endforeach; ?>
share|improve this answer

make a try on WordPress Popular Posts Plugin. In this Plugin we having the option to sort with comment for popular post.:)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.