WP_Query::query() WordPress Method

The WP_Query::query() method is used to query the WordPress database. It takes an array of arguments, which can be used to customize the query. The most important argument is the 'post_type' argument, which is used to determine what type of data to query. Other arguments include 'tax_query', 'meta_query', and 'date_query'.

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

Sets up the WordPress query by parsing query string.


Description

Top ↑

See also


Top ↑

Parameters

$query

(string|array)(Required)URL query string or array of query arguments.


Top ↑

Return

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


Top ↑

Source

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

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


Top ↑

Changelog

Changelog
VersionDescription
1.5.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.