How can I show the number of unpublished comments for each post in a theme? I have searched, but I found nothing.

I also need to show published comments number for each post.

  • By WordPress theme, do you mean the theme options, else you can always see the comments published and unpublished(or waiting approval) in the dashboard – Maruti Mohanty Jan 13 '14 at 11:16
  • @MarutiMohanty i khow that. i want to show that for my visitors. – user3159807 Jan 13 '14 at 11:18

I wonder if you're looking for the wp_count_comments() function.

To retreive comment count statistics for the whole site, you can use:

$comments_count = wp_count_comments();

or for a given post ID:

$comments_count = wp_count_comments( 123 );

It will return an object with the following attributes:


Check the Codex for more information and examples.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.