(+84) 463.28.7979

Display the Comment Stats on Your Advertising Page in WordPress


We can see the number of comments made in our dashboard, but our advertisers cannot see that. If you have a page for advertisers, you want to add this number to give them one more reason to buy advertisement on your site. Specially when you are selling ads towards the comment area.

Good Bye Mystery Man

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

<?php
$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 audience, how many total comments your blog has, and an average number of comments on each post. Sometimes the per post number might be a decimal, but this code rounds it up to an integer value.

You can also show this number in your sidebar as a statistic if you so desire.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>