Technology

How to display the most accurate comment count in WordPress

2025-03-24 11:51:36


If you have ever noticed the comments section of a website, you might see numbers indicating the number of comments received for each blog post. These numbers are not just statistics; they also reflect the level of engagement and activity of the community on your website.


If you want to display the most accurate number of comments on your WordPress website, this article will help you do it easily.




Why should the number of valid comments be displayed in WordPress?

Comments allow readers to interact with you and other visitors, which can create a strong community and encourage people to return to your website. Therefore, you should find ways to increase the number of comments, such as:

  • Allow users to subscribe to comment notifications.
  • Encourage conversation by asking a question at the end of each post.
  • Show the accurate number of comments to encourage user participation.

However, WordPress does not have a default option to automatically display the correct number of comments, especially if your website receives a lot of trackbacks and pings, or if there are unapproved comments. So, let's learn how to accurately display the number of comments using a free plugin.



How to display the exact number of comments in WordPress

Method 1: Use the Simple Blog Stats plugin (easy and quick)

The Simple Blog Stats plugin is the easiest way to display the number of approved comments and comments in the moderation queue. However, this plugin does not count pings and trackbacks.

Usage instructions:

  • Install and activate the Simple Blog Stats plugin.
  • Go to Settings » Simple Blog Stats and check the list of available shortcodes.
  • Use the shortcode [sbs_approved] to display the number of approved comments.
  • If you want to comment on something that is in the review queue, please use [sbs_comments].
  • Place the shortcode in your post or widget, then check the results.

If you need more details about using shortcodes, please refer to the instructions on how to add shortcodes in WordPress.


Method 2: Use Custom Shortcode (including trackbacks, pings, and unapproved comments)

If you want to display the total number of comments, including trackbacks and pings, you can use additional PHP code to create a custom shortcode.

Usage instructions:

  • Install and activate the WPCode plugin
  • Go to Code Snippets » + Add Snippet
  • Select the PHP Snippet and insert the following code into the editor:

function wp_custom_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);

    return get_comments_number();

}

add_shortcode('actual_comment_count', 'wp_custom_comment_count');


  • Set the code to run everywhere (Run Everywhere)
  • Save and activate the code
  • Use the shortcode [actual_comment_count] to display the accurate comment count anywhere on your website.



How to display the number of comments for a specific post

If you want to display the number of comments for a specific post or page, use the following code in WPCode:


function wp_custom_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);

    return get_comments_number();

}

add_shortcode('post_comment_count', 'wp_custom_post_comment_count');


Then use the shortcode [post_comment_count] in the post or page where you want to display the specific comment count.



Additional tip: Use Thrive Comments to boost engagement.

If you want to increase comments on your website, we recommend using Thrive Comments, a plugin that enhances the efficiency of the commenting system with the following features:

  • Allow users to like/dislike comments.
  • Upvote and downvote system for popular comments
  • Set up actions after commenting, such as redirecting to related posts or subscription forms.




Displaying accurate comment counts can help increase engagement on your website. If you want a simple and quick method, you can use the Simple Blog Stats plugin. However, if you want to include trackbacks and pings, you can use a Custom Shortcode through the WPCode plugin.


We hope this article will help you easily display the correct number of comments on your WordPress website. If you're interested in increasing website traffic, please check out our guide on boosting blog traffic.

Leave a comment :