wp_count_comments
wp_count_comments ( $post_id = 0 )
Parameters:- (int) post_id Optional. Restrict the comment counts to the given post. Default 0, which indicates that comment counts for the whole site will be retrieved.
See:Returns:- (stdClass) { The number of comments keyed by their status. @type int $approved The number of approved comments. @type int $moderated The number of comments awaiting moderation (a.k.a. pending). @type int $spam The number of spam comments. @type int $trash The number of trashed comments. @type int $post-trashed The number of comments for posts that are in the trash. @type int $total_comments The total number of non-trashed comments, including spam. @type int $all The total number of pending or approved comments. }
Defined at: - Introduced in WordPress: 2.5.0
- Deprecated in WordPress: —
Description
Retrieves the total comment counts for the whole site or a single post.The comment stats are cached and then retrieved, if they already exist in the
cache.