get_comments_number()
最后更新于:2021-11-26 08:01:21
get_comments_number( int|GC_Post$post_id)Retrieves the amount of comments a post has.
参数
响应
(string|int) If the post exists, a numeric string representing the number of comments the post has, otherwise 0.
源文件
文件: gc-includes/comment-template.php
function get_comments_number( $post_id = 0 ) {
$post = get_post( $post_id );
if ( ! $post ) {
$count = 0;
} else {
$count = $post->comment_count;
$post_id = $post->ID;
}
/**
* Filters the returned comment count for a post.
*
* @since 1.5.0
*
* @param string|int $count A string representing the number of comments a post has, otherwise 0.
* @param int $post_id Post ID.
*/
return apply_filters( 'get_comments_number', $count, $post_id );
}