On this page
WP_Query::query( string|array $query ): WP_Post[]|int[]
Sets up the WordPress query by parsing query string.
Description
See also
- WP_Query::parse_query(): for all available arguments.
Parameters
$querystring|array Required-
URL query string or array of query arguments.
Return
WP_Post[]|int[] Array of post objects or post IDs.
Source
File: wp-includes/class-wp-query.php. View all references
public function query( $query ) {
$this->init();
$this->query = wp_parse_args( $query );
$this->query_vars = $this->query;
return $this->get_posts();
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Query::get_posts() wp-includes/class-wp-query.php | Retrieves an array of posts based on query variables. |
| WP_Query::init() wp-includes/class-wp-query.php | Initiates object properties and sets default values. |
| wp_parse_args() wp-includes/functions.php | Merges user defined arguments into defaults array. |
Used By
| Used By | Description |
|---|---|
| WP_Query::__construct() wp-includes/class-wp-query.php | Constructor. |
Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_query/query