Modify `meta_query orderby syntax to use array keys as clause "handles".

The implementation of `meta_query` orderby introduced in [31312] put clause
identifiers into a 'name' parameter of the clause. For greater clarity, this
changeset updates the syntax to use the associative array key used when
defining `meta_query` parameters, instead of the 'name' parameter.

Props Funkatronic, DrewAPicture.
Fixes #31045.

git-svn-id: https://develop.svn.wordpress.org/trunk@31340 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2015-02-05 19:37:47 +00:00
parent 9d72e1c6a2
commit 0f28011bcf
3 changed files with 75 additions and 32 deletions

View File

@@ -1450,6 +1450,8 @@ class WP_Query {
* Parse a query string and set query type booleans.
*
* @since 1.5.0
* @since 4.2.0 Introduced the ability to order by specific clauses of a `$meta_query`, by passing the clause's
* array key to `$orderby`.
* @access public
*
* @param string|array $query {
@@ -1497,11 +1499,14 @@ class WP_Query {
* @type int $offset The number of posts to offset before retrieval.
* @type string $order Designates ascending or descending order of posts. Default 'DESC'.
* Accepts 'ASC', 'DESC'.
* @type string $orderby Sort retrieved posts by parameter. One or more options can be
* @type string|array $orderby Sort retrieved posts by parameter. One or more options may be
* passed. To use 'meta_value', or 'meta_value_num',
* 'meta_key=keyname' must be also be defined. Default 'date'.
* Accepts 'none', 'name', 'author', 'date', 'title', 'modified',
* 'menu_order', 'parent', 'ID', 'rand', 'comment_count'.
* 'meta_key=keyname' must be also be defined. To sort by a
* specific `$meta_query` clause, use that clause's array key.
* Default 'date'. Accepts 'none', 'name', 'author', 'date',
* 'title', 'modified', 'menu_order', 'parent', 'ID', 'rand',
* 'comment_count', 'meta_value', 'meta_value_num', and the
* array keys of `$meta_query`.
* @type int $p Post ID.
* @type int $page Show the number of posts that would show up on page X of a
* static front page.