Free Wordpress Blog Setup

Display the Comment Stats on Your Advertising Page in WordPress

By Editorial Staff in Tutorials
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.

What Next?

Digg it
Save This Page
Subscribe to WPBeginner
Stumble it
Free Wordpress Blog Setup

Comments

No Responses to “Display the Comment Stats on Your Advertising Page in WordPress”

Share Your Opinions

Tell us what you're thinking...
and if you want a pic to show with your comment, then get gravatar!

Please make sure that you have read our Comment Policy.

Due to high volume of request from our readers, we are adding this feature that allows you to stay updated with this post's comments without having to participate in the discussion even though we would love your input as always. Don't worry we hate SPAM just as much as you do, so you will never receive any SPAM messages from our site and that's our promise to you.

Subscribe without commenting

Close Bar