Do you want to show off number of comments in WordPress posts to your readers? Showing the number of comments can encourage users to comment on the post and read the post If the user didn’t read the WordPress post already. In this article I will show you 2 easy methods to display total number of comments in WordPress.

Method 1- Using a WordPress Plugin

This method is easiest though I do not use it. I recommend this method If you do not know coding. You will need to install a plugin called “Simple Blog Stats” and activate the plugin. To install the plugin, just go to plugins, add new plugin search and install. Then activate WordPress plugin.

After activating the plugin, go to  setting and simple blogs stats in setting tab. The plugin allows you to show your blog stats using shortcodes and template tags. You can show different stats using this plugin. Not just number of comments.  For example, registered users can be shown using this plugin.

You need to copy the shortcode [sbs_approved] to display the total number of approved comments on your WordPress site.

Now paste this short code on anywhere you want to show this in. For example, If you wanna show this before header. Go to appearance editor and add this code before header tag. You can easily post these on any WordPress post or page.

 

Method 2- Using The Code

This method requires you to edit WordPress files. If you are doubtful, create a backup of the files you are going to edit. So you can restore them using FTP.

First, you will need to add this code to your theme’s functions.php file using Appearance> File editor

function wpb_comment_count() { 

$comments_count = wp_count_comments();
$message =  'There are <strong>'.  $comments_count->approved . '</strong> comments posted by our users.';

return $message; 

} 

add_shortcode('wpb_total_comments','wpb_comment_count'); 
add_filter('widget_text','do_shortcode');

This code simply creates a function that outputs total number of approved WordPress comments on your site. It then creates a shortcode to display it. You can customize the output message as needed.

Now, you can use the shortcode [wpb_total_comments] in your WordPress posts, pages, or text widget to display total number of comments on your site.

If you like this post, please comment and share this post on social media.

SHARE
Previous articleWhat is SiteLock Security and its Uses.
Next articleHow to Write a Humorous WordPress Post
My name is Ahmed Nazeeh. I was born in 22nd November 1997. I do blogging as a hobby. Its not just that it's my hobby. I am also a WordPress expert. I helped many wordpress beginners create and run their website.

Leave a Comment