Uma área de pesquisa sobre o WordPress para devs e autores do tema



get_approved_comments ›

Desde2.0.0
Obsoleton/a
get_approved_comments ( $post_id, $args = array() )
Parâmetros: (2)
  • (int) $post_id The ID of the post.
    Required: Yes
  • (array) $args Optional. See WP_Comment_Query::__construct() for information on accepted arguments.
    Required: No
    Padrão: array()
Retorna:
  • (int|array) $comments The approved comments, or number of comments if `$count` argument is true.
Definido em:
Codex:
Log de mudanças:
  • 4.1.0

Retrieve the approved comments for post $post_id.



Fonte

function get_approved_comments( $post_id, $args = array() ) {
	if ( ! $post_id ) {
		return array();
	}

	$defaults = array(
		'status'  => 1,
		'post_id' => $post_id,
		'order'   => 'ASC',
	);
	$r = wp_parse_args( $args, $defaults );

	$query = new WP_Comment_Query;
	return $query->query( $r );
}