Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

2 Answers 2

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.


share|improve this answer

Your Answer


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