Call Me On 0807 708 8529

Do you want to display the total number of comments left on the main page of your site? Comments are known to be an important part of any content project. Leaving their feedback, users interact with your site, increase its attendance and search results.

If you show on the main page how many comments on your site, it can attract new users and encourage the appearance of new comments.

In this little lesson, we’ll show you how to easily display the total number of comments left on your WordPress site. Let’s get going.

Method 1. Displaying the number of comments with the plugin

This method is simpler, and we recommend it for all users.

You will need to install a free plugin Simple Blog Stats :

After activation, go to Settings → Simple Blog Stats to configure the plugin.

The plugin can display statistics on your site with the help of shortcodes. On the settings page, you will see a full list of shortcodes that display different information, such as the number of comments, the number of registered users, headings, tags, etc.

We are interested in the shortcode [ sbs_approved ] – it will display the total number of comments on the WordPress site.

Just copy this shortcode and use it anywhere on your website where you want to show the number of comments. This can be any record, page or plain text widget in the basement or on the sidebar of the main page of the site.

Method 2. Displaying the number of comments with the code

This method is considered more complicated, because it requires editing of files on your site.

You need to edit the file functions.php of your current theme and add the following code:

 function wpb_comment_count () {

$ Comments_count = wp_count_comments ();
$ Message = 'There are '. $ Comments_count-> approved. ' comments posted by our users.';

Return $ message;

}

Add_shortcode ('wpb_total_comments', 'wpb_comment_count');
Add_filter ('widget_text', 'do_shortcode');

This code creates a function that displays the total number of all confirmed comments on the WordPress site.

Also the code registers a new shortcode [ wpb_total_comments ]which, by analogy with the example above, will output the number of comments in the place where you paste it.

For example, this is how it will look on the site:

You can edit the accompanying text in the sample code at your discretion.

That’s it! Ihve showed 2 simple examples of how you can display the total number of your comments on the WordPress site using the plugin and code insertion.

Leave a Reply

Your email address will not be published. Required fields are marked *

Copy Protected by Chetan's WP-Copyprotect.