Posted By

laurentzziu on 11/15/10


Tagged

wordpress posts popular most commented


Versions (?)

Wordpress Popular Posts


 / Published in: PHP
 

  1. <h2>Popular Posts</h2>
  2. <ul>
  3. <?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5");
  4. foreach ($result as $post) {
  5. setup_postdata($post);
  6. $postid = $post->ID;
  7. $title = $post->post_title;
  8. $commentcount = $post->comment_count;
  9. if ($commentcount != 0) { ?>
  10.  
  11. <li><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>">
  12. <?php echo $title ?></a> {<?php echo $commentcount ?>}</li>
  13. <?php } } ?>
  14.  
  15. </ul>

Report this snippet  

You need to login to post a comment.