How to Display the Total Number of Comments in WordPress?

Are you looking forward to displaying the total number of comments on your WordPress website?. If yes, this blog will explain how to display it.

Comments in WordPress allow the users to engage with your content. You can show the total count on your WordPress post so that it might encourage more users to get engaged with the conversation.

In this post, you will learn how to easily display the total number of comments using both using a plugin and without a plugin.

How to Display WordPress Comment Count using a Plugin?

Using a plugin is one of the easiest ways to display the WordPress comment especially if you are a non-technical user.

Follow the below steps to display the WordPress comment Count using a plugin.

  1. Install and activate the Simple Blog Stats plugin from your WordPress plugins page.
  2. Once you have activated the plugin, navigate to Settings -> Simple Blog Stats in the left sidebar to get the shortcode that you use to show different stats.
  3. Copy the shortcode [sbs_approved] to display the total number of approved comments on your WordPress website.
  4. To display the total number of comments in a post or page, add a shortcode block via the WordPress content editor and add the shortcode [sbs_approved] 
  5. If you want to display the total comment count in the sidebar widget, simply add a text widget to the sidebar and paste the shortcode.

Once you save and open your WordPress site(page/post), you should start seeing the comment count.

How to Display WordPress Comment Count without using a plugin?

If you don’t want to use a plugin and you are comfortable with the PHP and WordPress codebase, you can do that manually too.

Note that you will need to make a full backup of your WordPress website before you change anything so that you can always restore it if something goes wrong.

Open your theme’s functions.pho file and add the below code snippet.

function wpb_comment_count() { 
$comments_count = wp_count_comments();
$message = 'There are <strong>'. $comments_count->approved . '</strong>Total Comments.';
return $message; 
} 
 
add_shortcode('wp_total_comments','wpb_comment_count'); 

Once you save this, you can use the shortcode , [wp_total_comments] in your posts or pages to display the total number of comments on your WordPress website.