How to Display the Most Accurate Comment Count in WordPress
Do you want to see the most display accurate comment count in WordPress?
Your WordPress site may contain pending moderation comments, spam, trackbacks, and pings. This makes it impossible to display an accurate comment count on your website.
This article will demonstrate how to display the most accurate comment count on your WordPress website.
Why Display an Accurate Comment Count in WordPress?
Comments allow readers to communicate with you and other visitors. This can help foster a sense of community and keep visitors returning to your website. Therefore, you’ll want to increase the number of comments on your WordPress posts.
You may allow users to subscribe to comments, end each post with a question to spark discussion and more. Another alternative is to show an exact comment count.
Visitors will be more likely to join the debate if there are many comments. It also serves as social proof, as readers may visit your posts to check why so many people are commenting.
There is no default way to display an accurate comment count in WordPress, especially if your site receives a lot of trackbacks and pings. Comment spam might make it difficult to do so.
With that said, let’s look at how to display an accurate comment count on your WordPress website using free plugins. Simply use the quick buttons below to move directly to the method you want to use.
Method 1: Using Simple Blog Stats (Quick and Easy)
The simplest way to display an accurate comment count is to use Simple Blog Stats. This plugin displays the total number of approved comments and those in moderation. However, it does not include bounces or trackbacks in its count.
Many websites disable trackbacks and pingbacks to avoid spam comments in WordPress, so this may not be a significant issue for your site. However, if you wish to incorporate trackbacks and feeds in your comment count, we propose Method 2.
To get started, install and activate the Simple Blog Stats plugin. For additional information, visit our step-by-step tutorial on how to install a WordPress plugin.
After activating the plugin, navigate to the Settings » Simple Blog Stats page to view all of its shortcodes.

Simply click to expand the ‘Shortcodes‘ section.
To show the total number of allowed comments on your WordPress blog, use the following shortcode: [sbs_approved]

If you want to show the total number of approved comments plus comments that are still in the WordPress comment moderation queue, then you can use [sbs_comments] instead.
For further details on where to position the shortcode, please check our WordPress shortcode tutorial.
After you’ve included the shortcode, go to your WordPress site to see the total number of comments live.
Method 2: Using a Custom Shortcode (Includes Pings, Trackbacks, and Unapproved Comments)
If you wish to incorporate pingbacks and trackbacks in the total comment count, you must add custom code to your website.
Many tutorials instruct you to add custom code snippets to your theme’s functions.php file. However, we discourage this strategy because a minor inaccuracy in your code can result in a variety of frequent WordPress issues. Or, worse, completely damage your website.
This is why we recommend using WPCode. It is the simplest and safest approach to add custom code to WordPress without modifying any WordPress theme files.
The first step is to install and activate the free WPCode plugin on your website. For additional information, visit our step-by-step tutorial on how to install a WordPress plugin.
Once activated, go to Code Snippets » Add Snippet.

This page contains all of WPCode’s ready-made snippets that you may use on your website.
We will design a custom shortcode that will allow you to display an accurate comment count on any page, post, or widget-ready location. To get started, hover your mouse over ‘Add Your Custom Code‘ and then select ‘Use Snippet.’

To begin, add a title for the custom code snippet. This might be anything that allows you to identify the snippet in your WordPress dashboard.
Simply open the ‘Code Type‘ selection and select ‘PHP Snippet.’

Once done, simply paste the following excerpt into the code editor:
function wpdruggy_comment_count() {
function comment_count( $count ) {
if ( ! is_admin() ) {
$comments_by_type = &separate_comments(get_comments('status=approve'));
return count($comments_by_type['comment']);
} else {
return $count;
}
}
add_filter('get_comments_number', 'comment_count', 0);
$actual_comment_count = get_comments_number();
return $actual_comment_count;
}
add_shortcode('actual_comment_count', 'wpdruggy_comment_count');
This code generates a WordPress shortcode, [actual_comment_count], that displays the overall number of approved comments on your entire website. It accomplishes this by verifying that the page is not in the admin area.
If not, it considers all allowed comments. If it’s in the admin section, it uses the default comment count. The count is then displayed anywhere you use the [actual_comment_count] shortcode on your website.
Insertion options appear below the code box.
To generate a shortcode that can be used on any page, post, or widget-ready area, open the ‘Location’ dropdown option and select ‘Run Everywhere.’
After that, navigate to the top of the screen and click ‘Inactive‘ to convert it to ‘Active.’
After that, simply click on ‘Save snippet‘ to publish the snippet on your website.

You now have a shortcode that can display an unlimited number of comments, including trackbacks, pings, and unapproved comments.
Simply include the [actual_comment_count] shortcode wherever you wish to display the comment count. For further details on where to position the shortcode, please check our WordPress shortcode tutorial.
Showing the Comment Count for a Specific WordPress Post
Do you want to see the number of comments for a specific post or page?
You can easily add the following PHP code snippet to WPCode using the same method outlined above:
function wpdruggy_post_comment_count() {
function comment_count( $count ) {
if ( ! is_admin() ) {
global $post;
$comments_by_type = &separate_comments(get_comments('status=approve&post_id='. $post->ID ));
return count($comments_by_type['comment']);
} else {
return $count;
}
}
add_filter('get_comments_number', 'comment_count', 0);
$actual_comment_count = get_comments_number();
return $actual_comment_count;
}
add_shortcode('post_comment_count', 'wpdruggy_post_comment_count');
Also, Read More Relevant Articles
- How to Display Ads Only to Search Engine Visitors in WordPress
- How to Remove Default Author Profile Fields in WordPress
- How to Disable Automatic Formatting in WordPress Posts
- How to Automatically Empty Your WordPress Trash
- How to Fix Yoast’s WordPress SEO Sitemap 404 Error
- How to Allow Users to Subscribe to Categories in WordPress
- How to Fix the Syntax Error in WordPress
- How to Fix WordPress Posts Returning 404 Error
- How to Upload an HTML Page to WordPress Without 404 Errors
- How to Fix PHP Missing MySQL Extension Error in WordPress
The Final Thought
Displaying the most accurate comment count in WordPress is critical for maintaining the integrity and engagement of your site. By optimizing your theme’s code, deploying comment plugins, and leveraging caching technologies, you can ensure that your visitors see the correct number of comments in real-time. Regular updates, testing, and monitoring can also help to keep the comment count correct. Implementing these tactics improves not only the user experience but also the site’s performance and reputation.
