query_posts( array|string $query )
Sets up The Loop with query parameters.
Description
Note: This function will completely override the main query and isn’t intended for use by plugins or themes. Its overly-simplistic approach to modifying the main query can be problematic and should be avoided wherever possible. In most cases, there are better, more performant options for modifying the main query such as via the ‘pre_get_posts’ action within WP_Query.
This must not be used within the ClassicPress Loop.
Parameters
- $query
-
(array|string) (Required) Array or string of WP_Query arguments.
Return
(array) List of post objects.
Source
File: wp-includes/query.php
function query_posts($query) {
$GLOBALS['wp_query'] = new WP_Query();
return $GLOBALS['wp_query']->query($query);
}
Changelog
Version | Description |
---|---|
WP-1.5.0 | Introduced. |