Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

3 Answers 3

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");

<ul>
foreach($popular as $posts) : ?>
<li> <?php echo $posts->post_title; ?> </li>
<?php endforeach; ?>
</ul>
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

 
discard

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.