1. 首页
  2. WordPress 函数手册

get_comments_number()

get_comments_number( int|WP_Post $post_id )

检索一篇文章的评论数量。
Retrieves the amount of comments a post has.

目录锚点:#参数#返回#源码#笔记


参数(Parameters)

参数 类型 必填 说明
$post_id (int | WP_Post) 可选 Post ID或WP_Post对象。默认值为全局$post。

返回(Return)

(string|int)如果post存在,则为表示该post具有的注释数的数字string,否则为0。


源码(Source)


更新版本 源码位置 使用 被使用
1.5.0 wp-includes/comment-template.php:848 5 3

笔记(Notes)

获取当前帖子评论数:

get_comments_number() 为WP2原创文章,链接:https://www.wp2.cn/functions/get_comments_number/