WordPress: How to Display The Total Number of Comments

WordPress How to Display The Total Number of Comments

Do you want to display the total number of comments on your WordPress blog without using any plugin? Remember the comments allow visitors to participate and engage with the content on your blog. By showing off the total comment count, you can encourage more visitors to post comments. In this article, I will show you how to easily display the total number of comments in WordPress without a plugin, by adding the following code to your theme’s functions.php – Follow the instructions below:

  1. Log into your WordPress Admin interface.
  2. Go to Appearance.
  3. Go to Theme Editor.
  4. In the right menu find functions.php
  5. Copy and paste the code below at the end of functions.php
  6. Publish.
/** *Total WordPress Comments*/
function wpm_comment_count() { 
$comments_count = wp_count_comments();
$message =  'There are '.  $comments_count->approved . ' comments posted by our visitors.';
return $message; 
} 
add_shortcode('wpm_total_comments','wpm_comment_count');

This code creates a function that outputs the total number of approved WordPress comments on your site. It also creates a short-code to display it. You can now use the short-code [wpm_total_comments] in your posts, pages, or a text widget to display the total number of comments on your website. Remember: You will only see a total of approved WordPress comments.

paypal This article is free, but powered by your donations. Updated on