Summery Summery
Retrieves the total comment counts for the whole site or a single post.
Syntax Syntax
Description Description
The comment stats are cached and then retrieved, if they already exist in the cache.
Parameters Parameters
- $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.
Return Return
(stdClass) The number of comments keyed by their status.
- 'approved'
(int|string) The number of approved comments. - 'moderated'
(int|string) The number of comments awaiting moderation (a.k.a. pending). - 'spam'
(int|string) The number of spam comments. - 'trash'
(int|string) The number of trashed comments. - 'post-trashed'
(int|string) The number of comments for posts that are in the trash. - 'total_comments'
(int) The total number of non-trashed comments, including spam. - 'all'
(int) The total number of pending or approved comments.
Source Source
File: wp-includes/comment.php
* @param string $email Comment author's email. * @param string $url Comment author's URL. * @param string $comment Comment content. * @param string $user_ip Comment author's IP address. * @param string $user_agent Comment author's browser user agent. */ do_action_deprecated( 'wp_blacklist_check', array( $author, $email, $url, $comment, $user_ip, $user_agent ), '5.5.0', 'wp_check_comment_disallowed_list', __( 'Please consider writing more inclusive code.' ) ); /** * Fires before the comment is tested for disallowed characters or words. * * @since 5.5.0 * * @param string $author Comment author. * @param string $email Comment author's email. * @param string $url Comment author's URL. * @param string $comment Comment content. * @param string $user_ip Comment author's IP address. * @param string $user_agent Comment author's browser user agent. */ do_action( 'wp_check_comment_disallowed_list', $author, $email, $url, $comment, $user_ip, $user_agent ); $mod_keys = trim( get_option( 'disallowed_keys' ) ); if ( '' === $mod_keys ) {
Advertisement
Changelog Changelog
Version | Description |
---|---|
2.5.0 | Introduced. |
See also See also
- get_comment_count(): Which handles fetching the live comment counts.