How to Display the Total Number of Comments in WordPress

Here’s a handy WordPress code snippet which allows you to display the total number of comments on your WordPress blog. In this snippet, we are going to use a built-in WordPress function wp_count_comments().

Useful Read : Automatically spam comments with a very long url

// Display total number of approved comments
$count_comments = wp_count_comments();
$approved_comments = $count_comments->approved;
echo $approved_comments . ' comments. ';

The above code will display, only approved comments. For more information visit WordPress Codex Website.


Leave a Comment.