How to Display Accurate Comment Count in WordPress
How to Display Accurate Comment Count in WordPress

Do you want WordPress to show the most accurate comment count?

Your WordPress site may have pending moderation comments, spam, trackbacks, and pings. There is no straightforward method to display the precise number of comments on your WordPress site by default. Yet, we should begin with the rudiments.

What are the blog remarks?

Blog remarks are composed answers to your blog postings that a reader can add. Leaving a remark on a blog article permits your guests to interface with you and different readers without any problem.

You can also watch the video tutorial here:

Remarks ordinarily show on your webpage following the blog entry content, alongside the commenter’s name, the date and time they left the comment.

A dynamic comment section may help you and your readers develop a community around your site. Visitors can provide feedback, ask questions, express their own opinions on the subject, and more.

It is usually preferable to present an exact comment count when displaying a comment count. WordPress automatically adds your trackbacks and pings in the overall count, which inflates the total. You must ensure that you are displaying the correct count, especially on blogs that do not display trackbacks or have them segregated from the comments. 

We’ll teach you how to simply display the most accurate comment count in WordPress in this post.

  • Firstly, open your WordPress Admin dashboard.
  • Hover on to Appearances.
  • After that, just simply go and tap on Theme Editor.
  • Go on and simply tap on Theme Functions from the right hand side of the screen.
  • Scroll downwards until you finally reach the end of the screen.
  • Now, you have to add a small piece of code.
How to Display Accurate Comment Count in WordPress

NOTE: Before making any code-related changes, it is suggested to have a backup of your website JUST IN CASE anything goes wrong, then you can at least restore it afterwards.

Code:

add_filter('get_comments_number', 'comment_count', 0);
function comment_count( $count ) {
if ( ! is_admin() ) {
global $id;
$comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id));
return count($comments_by_type['comment']);
} else {
return $count;
}
} 
How to Display Accurate Comment Count in WordPress
  • Further, click on the Update File.

Now, you can go ahead and check in your website whether the comment count is being accurately displayed as per your need. 

As long as you followed our steps correctly, you must have achieved displaying the accurate comment count for your WordPress posts.

In case you have more queries, and require more help, feel absolutely free to check out our website or contact Digital Suncity.

Also Read: How To Embed A Facebook Video In WordPress 

0 Comments

Submit a Comment

Your email address will not be published.

Need Professional Help?

We can help you with website fixes and ongoing maintenance.