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 !

3 Answers 3


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

$posts  = get_posts( array(
                 'numberposts' => 10,
                 'orderby' => 'comment_count',
                 ) );

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; ?>

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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