WP_Comment_Query::query() WordPress Method

The query() method is used to query the database for comments. The method accepts an array of arguments, which are used to narrow the search. Comments can be retrieved by post ID, author, status, type, parent, and more.

WP_Comment_Query::query( string|array $query ) #

Sets up the WordPress query for retrieving comments.


Parameters

$query

(string|array)(Required)Array or URL query string of parameters.


Top ↑

Return

(array|int) List of comments, or number of comments when 'count' is passed as a query var.


Top ↑

Source

File: wp-includes/class-wp-comment-query.php

	public function query( $query ) {
		$this->query_vars = wp_parse_args( $query );
		return $this->get_comments();
	}


Top ↑

Changelog

Changelog
VersionDescription
4.2.0Moved parsing to WP_Comment_Query::parse_query().
4.1.0Introduced 'comment__in', 'comment__not_in', 'post_author__in', 'post_author__not_in', 'author__in', 'author__not_in', 'post__in', 'post__not_in', 'include_unapproved', 'type__in', and 'type__not_in' arguments to $query_vars.
3.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.