Posted By

howardpanton on 04/12/10


Tagged

wordpress count comments


Versions (?)

Wordpress Comment counts


 / Published in: PHP
 

Count the number of comments in wordpress blog

  1. <?php /* Counts the posts, comments and categories on your blog */
  2. $numposts = $wpdb->get_var("SELECT COUNT(1) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type != 'page'");
  3. if (0 < $numposts) $numposts = number_format($numposts);
  4.  
  5. $numcomms = $wpdb->get_var("SELECT COUNT(1) FROM $wpdb->comments WHERE comment_approved = '1'");
  6. if (0 < $numcomms) $numcomms = number_format($numcomms);
  7.  
  8. $numcats = count(get_all_category_ids());
  9. ?>

Report this snippet  

You need to login to post a comment.