Quantcast
Channel: WordPress Experts
Viewing all articles
Browse latest Browse all 33

How to Display Your Average Comments Per Post in WordPress!

$
0
0

display average comment postIf your blog is running on high rank and gets lots of comments then its difficult to know about average comments per posts. But today i am going to share with you a tip that how you can display your average comments per posts in WordPress using new functions introduced in WordPress 2.7!

To do this, you have to simply paste the below code anywhere on your theme, where you’d like the average comments per post to be displayed:

<?php
$count_posts = wp_count_posts();
$posts = $count_posts->publish;

$count_comments = get_comment_count();
$comments  = $count_comments['approved'];

echo "Average ".round($comments/$posts)." comments per post.";
?>

 

The code is given in this post is quite simple, Through this first, we get the total number of published posts and the total number of approved comments. Once we have it, we just have to divide the number of comments by the number of posts.

If you enjoyed this article , please consider sharing it!!

 

The post How to Display Your Average Comments Per Post in WordPress! appeared first on WordPress Experts.


Viewing all articles
Browse latest Browse all 33

Latest Images

Trending Articles



Latest Images