get_approved_comments()

最后更新于:2021-11-26 04:13:51

get_approved_comments( int$post_id, array$args=array())

Retrieve the approved comments for post $post_id.

参数

$post_id

(int) (Required) The ID of the post.

$args

(array) (Optional) See GC_Comment_Query::__construct() for information on accepted arguments.

Default value: array()

响应

(int|array) The approved comments, or number of comments if $count argument is true.

源文件

文件: gc-includes/comment.php

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 = gc_parse_args( $args, $defaults );

	$query = new GC_Comment_Query;
	return $query->query( $parsed_args );
}