How to Display Comments Counts in WordPress

How to Display Comments Counts in WordPress

We usually see the number of WordPress comments made on our dashboard, but none of your advertisers cannot see that. If you have a page for advertisers, you might want to add this number to give them more reasons to buy advertisement space on your site. Especially when you are selling ads towards the comment area.

How to Display Comments Count in WordPress

All you have to do is paste the following code in a page where you want it displayed:

$count_posts = wp_count_posts();
$posts = $count_posts->publish; 
$count_comments = get_comment_count();
$comments = $count_comments['approved']; 
echo "There's a total of ".$comments." comments on my blog, with an average ".round($comments/$posts)." comments per post.";

This code will tell your advertisers or your site visitors, total comments your blog has, and the average number of comments on each of your posts. But sometimes, the per post number might be a decimal, but this code rounds it up to an integer value.

Read: How to Re-arrange Comments in WordPress 

If you have found a spelling error, please, notify us by selecting that text and pressing Ctrl+Enter.

Related Post

Also Read  Install WordPress on Local PC

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close Menu


Spelling error report

The following text will be sent to our editors: