Wordpress Comment counts


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

Count the number of comments in wordpress blog


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.