X

Display total number of comments

You can easily show of how many comments there are on your WordPress blog by adding this clever little snippet.

Add this code to where you want to show the total amount of comments.

Code Snippet:

<?php 
$numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'"); 
if (0 < $numcomms) {
	$numcomms = number_format($numcomms); 
	echo "There's ".$numcomms." total comments on my blog";
}
?>

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!