WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to find out the number of comments in total I have and display the number on my website.

share|improve this question

Hi @stubudz:

You are trying to make things easy on me today, right? :)

Here's what you need:

$comment_counts = get_comment_count();
echo $comment_counts['approved'];
//print_r($comment_counts); // Uncomment to see all from get_comment_count()
share|improve this answer
Also wp_count_comments() ( source ), this one caches results which makes a difference if this needs to be fetched several times or persistent object cache is used. – Rarst Dec 27 '10 at 14:46
@Rarst - Good point. – MikeSchinkel Dec 27 '10 at 17:35
$numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
if (0 < $numcomms) $numcomms = number_format($numcomms);

There are <?php echo $numcomms; ?> in this blog.

source http://www.wprecipes.com/how-to-display-the-total-number-of-comments-on-your-wordpress-blog

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.