Number of unpublished comments for each post

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.


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.

Source : Link , Question Author : user3159807 , Answer Author : birgire

Leave a Comment