Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Display the Total Number of Comments in WordPress

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Display the Total Number of Comments in WordPress

Have you ever seen sites that show off their total RSS subscribers count, twitter follower count, and other vanity counts? Well let’s add one more to that list. Total comment counts. If you have a very engaged community, then it is a great idea to show off the total number of comments in your WordPress sidebar.

All you have to do is open your sidebar.php file, and paste the following code:

$comments_count = wp_count_comments();
echo $comments_count->approved . " Comments, care to join in?";

Feel free to style the code in any way you like. Let us know if you have any questions.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Konstantin says:

    Is wp_count_comments() not good enough for you?

    • Editorial Staff says:

      Does that echo the total comment count in WordPress or the total count of comments on a specific post? The goal of our trick is to show the total number of comments made on the site.

      • Konstantin says:

        If a post ID is not provided, it returns the total number of comments.
        This function is used to display the total number of comments in the ‘right now’ dashboard widget. You can find it in wp-includes/comment.php

  2. GrimCris says:

    Something like this for the post count? Thanks!

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.