Learn to display number of comments in WordPress Content Management System

Learn to display number of comments in WordPress Content Management System

Life Swift
Published on September 23, 2023
Learn to display number of comments in WordPress Content Management System

In this article, we will provide you guide so that you can display the total number of comments in WordPress:

Method 1: Display WordPress Comment count with a plugin

Inorder to display WordPress comment count with a plugin, follow the steps below:

  1. Install and activate Simple Blog Stats

  2. After activated, Goto Setting > Simple Blog Stats. This plugin shows your blog stats using shortcodes and template tag. Demo picture is shown below:
  3. As shown in the figure above, you need to copy shortcode[sbs_approved]to display total number of approved comments on your site.

Note: you can use this code in any WordPress post, page or text widget.

 

Method2: Display WordPress comment count with code

This method could be quite difficult for you as you need to add code to your WordPress site. But still, if you want to display comment count without the use of plugin then you may follow the steps below:

  1. Copy the code below to your theme’s functions.php file or a site-specific plugin.

[php]

function ibsam_comment_count() {
$comments_count = ibsam_count_comments();
$message = ‘There are ‘. $comments_count->approved . ‘ comments found.’;
return $message;
}

add_shortcode(‘ibsams_comment_count’,’ibsam_comment_count’);
add_filter(‘widget_text’,’do_shortcode’);

[/php]

Note: this code creates a function that outputs total number of approved WordPress comments on your site.