Wordpress - Display the Most Commented Posts of 2009


/ Published in: PHP
Save to your folder(s)

From Web Design Ledger "13 Useful Code Snippets for WordPress Development"
For additional information, see the link above.


Copy this code and paste it in your HTML
  1. <ul>
  2. <?php
  3. $result = $wpdb->get_results("SELECT comment_count,ID,post_title, post_date FROM $wpdb->posts WHERE post_date BETWEEN '2009-01-01' AND '2009-12-31' ORDER BY comment_count DESC LIMIT 0 , 10");
  4.  
  5. foreach ($result as $topten) {
  6. $postid = $topten->ID;
  7. $title = $topten->post_title;
  8. $commentcount = $topten->comment_count;
  9. if ($commentcount != 0) {
  10. ?>
  11. <li></li>
  12. <?php }
  13. }
  14. ?>
  15. </ul>

URL: http://webdesignledger.com/tips/13-useful-code-snippets-for-wordpress-development

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.