Docs: Add a note to the DocBlock for `query_posts()` to caution against general usage, including a pointer to the `pre_get_posts` action.

Also adds missing parameter and return descriptions.

See #32246.


git-svn-id: https://develop.svn.wordpress.org/trunk@37877 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Drew Jaynes 2016-06-26 17:46:10 +00:00
parent 36e36e3b1d
commit 6089491477
1 changed files with 8 additions and 5 deletions

View File

@ -77,17 +77,20 @@ function set_query_var( $var, $value ) {
}
/**
* Set up The Loop with query parameters.
* Sets up The Loop with query parameters.
*
* This will override the current WordPress Loop and shouldn't be used more than
* once. This must not be used within the WordPress Loop.
* Important: This will completely override the current WordPress Loop and can easily
* produce unexpected results. In most cases, the better option is to instead modify
* specific properties of the loop using the {@see 'pre_get_posts'} action.
*
* This must not be used within the WordPress Loop.
*
* @since 1.5.0
*
* @global WP_Query $wp_query Global WP_Query instance.
*
* @param string $query
* @return array List of posts
* @param array|string $query Array or string of WP_Query arguments.
* @return array List of post objects.
*/
function query_posts($query) {
$GLOBALS['wp_query'] = new WP_Query();