wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



get_approved_comments › WordPress Function

Seit2.0.0
Veraltetn/v
get_approved_comments ( $post_id, $args = array() )
Parameter: (2)
  • (int) $post_id The ID of the post.
    Erforderlich: Ja
  • (array) $args { Optional. See WP_Comment_Query::__construct() for information on accepted arguments. @type int $status Comment status to limit results by. Defaults to approved comments. @type int $post_id Limit results to those affiliated with a given post ID. @type string $order How to order retrieved comments. Default 'ASC'. }
    Erforderlich: Nein
    Standard: array()
Gibt zurück:
  • (WP_Comment[]|int[]|int) The approved comments, or number of comments if `$count` argument is true.
Definiert in:
Codex:
Changelog:
  • 4.1.0

Retrieves the approved comments for a post.



Quellcode

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 );
}