get_approved_comments
函数
get_approved_comments ( $post_id, $args = array() )
- 参数
-
-
(int)
$post_id
The ID of the post.- Required: 是
-
(array)
$args
Optional. See WP_Comment_Query::__construct() for information on accepted arguments.- Required: 否
- Default: array()
-
(int)
- 返回值
-
- (WP_Comment[]|int[]|int) The approved comments, or number of comments if `$count` argument is true.
- 定义位置
-
-
wp-includes/comment.php
, line 162
-
wp-includes/comment.php
- 引入
- 2.0.0
- 弃用
- –
Retrieves the approved comments for a post.
function get_approved_comments( $post_id, $args = array() ) {
if ( ! $post_id ) {
return array();
}
$defaults = array(
'status' => 1,
'post_id' => $post_id,
'order' => 'ASC',
);
$parsed_args = wp_parse_args( $args, $defaults );
$query = new WP_Comment_Query;
return $query->query( $parsed_args );
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。


