W3cubDocs

/WordPress

WP_Query::query( string|array $query ): WP_Post[]|int[]

Sets up the WordPress query by parsing query string.

Description

See also

Parameters

$querystring|arrayrequired
URL query string or array of query arguments.

Return

WP_Post[]|int[] Array of post objects or post IDs.

Source

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

Changelog

Version Description
1.5.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_query/query