首页 WordPress函数大全 get_comment_count()

get_comment_count()

2020-05-01 / 3656阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

get_comment_count( int $post_id )

Retrieves the total comment counts for the whole site or a single post.

描述

Unlike wp_count_comments(), this function always returns the live comment counts without caching.

参数

$post_id

(int)
(Optional)
Restrict the comment counts to the given post. Default 0, which indicates that comment counts for the whole site will be retrieved.

返回

(array()) The number of comments keyed by their status.

  • 'approved'
    (int|string) The number of approved comments.
  • 'awaiting_moderation'
    (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.
大家谈论
    我的见解