Family Encyclopedia >> Electronics

How to display the total number of comments in WordPress

Do you want to display the total number of comments on your WordPress site? Comments allow users to engage and engage with content on your WordPress site. By displaying your total comments, you can encourage more users to join the conversation. In this article, we will show you how to easily display the total number of comments in WordPress.

How to display the total number of comments in WordPress

Method 1. Show the number of WordPress comments with a plugin

This method is easier and is recommended for all users.

The first thing you need to do is install and activate the Simple Blog Stats plugin. For more details, check out our step-by-step guide on how to install a WordPress plugin.

Upon activation, you need to visit Settings »Simple blog statistics page to configure plugin settings.

How to display the total number of comments in WordPress

The plugin allows you to display your blog stats using shortcodes and template tags.

On this page you will see all the shortcodes that you can use to display different statistics such as the total number of comments, registered users, categories, tags and much more.

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

You can use this shortcode in any WordPress post, page or text widget. If the shortcode doesn't work in the text widget, check out our guide on how to use the shortcode in WordPress sidebar widgets.

Method 2. Show the number of WordPress comments with code

This method requires you to add code to your WordPress files. If you haven't done this before, check out our guide on how to copy paste code in WordPress.

First, you'll need to add this code to your theme's functions.php file or a site-specific plugin.

 función wpb_comment_count () $ comments_count = wp_count_comments (); $ mensaje = 'Hay '. $ comments_count-> aprobado. ' Comentarios publicados por nuestros usuarios. '; devuelve $ mensaje; add_shortcode ('wpb_total_comments', 'wpb_comment_count'); add_filter ('widget_text', 'do_shortcode'); 

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

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

This is what it looked like on our demo site.

How to display the total number of comments in WordPress

We hope this article has helped you display the total number of comments on your WordPress site. You can also check out 11 Ways to Get More Comments on Your WordPress Blog Posts.

If you enjoyed this article, please subscribe to our WordPress YouTube Channel video tutorials. You can also find us on Twitter and Facebook.