{"action":"created","issue":{"url":"https://api.github.com/repos/WP-API/WP-API/issues/2646","repository_url":"https://api.github.com/repos/WP-API/WP-API","labels_url":"https://api.github.com/repos/WP-API/WP-API/issues/2646/labels{/name}","comments_url":"https://api.github.com/repos/WP-API/WP-API/issues/2646/comments","events_url":"https://api.github.com/repos/WP-API/WP-API/issues/2646/events","html_url":"https://github.com/WP-API/WP-API/issues/2646","id":170037894,"number":2646,"title":"Advanced `orderby` clause array allowed in `filter` args by default?","user":{"login":"andrewmartin","id":273842,"avatar_url":"https://avatars.githubusercontent.com/u/273842?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewmartin","html_url":"https://github.com/andrewmartin","followers_url":"https://api.github.com/users/andrewmartin/followers","following_url":"https://api.github.com/users/andrewmartin/following{/other_user}","gists_url":"https://api.github.com/users/andrewmartin/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewmartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewmartin/subscriptions","organizations_url":"https://api.github.com/users/andrewmartin/orgs","repos_url":"https://api.github.com/users/andrewmartin/repos","events_url":"https://api.github.com/users/andrewmartin/events{/privacy}","received_events_url":"https://api.github.com/users/andrewmartin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"rmccue","id":21655,"avatar_url":"https://avatars.githubusercontent.com/u/21655?v=3","gravatar_id":"","url":"https://api.github.com/users/rmccue","html_url":"https://github.com/rmccue","followers_url":"https://api.github.com/users/rmccue/followers","following_url":"https://api.github.com/users/rmccue/following{/other_user}","gists_url":"https://api.github.com/users/rmccue/gists{/gist_id}","starred_url":"https://api.github.com/users/rmccue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmccue/subscriptions","organizations_url":"https://api.github.com/users/rmccue/orgs","repos_url":"https://api.github.com/users/rmccue/repos","events_url":"https://api.github.com/users/rmccue/events{/privacy}","received_events_url":"https://api.github.com/users/rmccue/received_events","type":"User","site_admin":false},"assignees":[{"login":"rmccue","id":21655,"avatar_url":"https://avatars.githubusercontent.com/u/21655?v=3","gravatar_id":"","url":"https://api.github.com/users/rmccue","html_url":"https://github.com/rmccue","followers_url":"https://api.github.com/users/rmccue/followers","following_url":"https://api.github.com/users/rmccue/following{/other_user}","gists_url":"https://api.github.com/users/rmccue/gists{/gist_id}","starred_url":"https://api.github.com/users/rmccue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmccue/subscriptions","organizations_url":"https://api.github.com/users/rmccue/orgs","repos_url":"https://api.github.com/users/rmccue/repos","events_url":"https://api.github.com/users/rmccue/events{/privacy}","received_events_url":"https://api.github.com/users/rmccue/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2016-08-08T22:10:46Z","updated_at":"2016-09-22T23:36:40Z","closed_at":"2016-09-22T23:36:40Z","body":"Hi there,\r\n\r\nThis may be a silly question, but I just spent ~3 hours trying to get this to work, and I'm confused why it's not.\r\n\r\nI'm trying to do an advanced `orderby` call to the API, using the methods shown here:\r\n\r\nhttps://make.wordpress.org/core/2014/08/29/a-more-powerful-order-by-in-wordpress-4-0\r\n\r\nHere's a pretty solid example / walkthrough of this feature as well:\r\nhttp://www.billerickson.net/wp-query-sort-by-meta/\r\n\r\nI was wondering if the WP JSON API out of box allows for a `filter[orderby]` array object; something like this:\r\n\r\n```    \r\n'meta_query' => array(\r\n      'relation' => 'AND',\r\n      'startDateClause' => array(\r\n        'compare' => 'EXISTS',\r\n        'key' => '_EventStartDate'\r\n      ),\r\n      'featuredClause' => array(\r\n        'key' => 'featured',\r\n        'type'    => 'NUMERIC'\r\n      ),\r\n      array(\r\n        'ageClause' => array(\r\n          'key' => 'age',\r\n          'value' => 'Babies',\r\n          'compare' => 'LIKE'\r\n        )\r\n      )\r\n    ),\r\n    'orderby' => array(\r\n      'featuredClause' => 'DESC',\r\n      'startDateClause' => 'ASC'\r\n    )\r\n```\r\n\r\nI have allowed `meta_query` in using the `rest_query_vars` filter, and I'm able to get results; but the Order is not working. I'm thinking that `orderby` is probably not needed below:\r\n\r\n```\r\nadd_filter( 'rest_query_vars', __NAMESPACE__ . '\\\\meta_keys_query_vars' );\r\nfunction meta_keys_query_vars( $valid_vars ){\r\n  $valid_vars = array_merge( $valid_vars, array(\r\n    'meta_query',\r\n    'date_query',\r\n    'orderby'\r\n  )\r\n); // Omit meta_key, meta_value if you don't need them\r\nreturn $valid_vars;\r\n}\r\n```\r\n\r\nWith a custom old fashioned `WP_Query` with the above arguments, I'm able to see the correct order. "},"comment":{"url":"https://api.github.com/repos/WP-API/WP-API/issues/comments/249058743","html_url":"https://github.com/WP-API/WP-API/issues/2646#issuecomment-249058743","issue_url":"https://api.github.com/repos/WP-API/WP-API/issues/2646","id":249058743,"user":{"login":"rmccue","id":21655,"avatar_url":"https://avatars.githubusercontent.com/u/21655?v=3","gravatar_id":"","url":"https://api.github.com/users/rmccue","html_url":"https://github.com/rmccue","followers_url":"https://api.github.com/users/rmccue/followers","following_url":"https://api.github.com/users/rmccue/following{/other_user}","gists_url":"https://api.github.com/users/rmccue/gists{/gist_id}","starred_url":"https://api.github.com/users/rmccue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmccue/subscriptions","organizations_url":"https://api.github.com/users/rmccue/orgs","repos_url":"https://api.github.com/users/rmccue/repos","events_url":"https://api.github.com/users/rmccue/events{/privacy}","received_events_url":"https://api.github.com/users/rmccue/received_events","type":"User","site_admin":false},"created_at":"2016-09-22T23:36:40Z","updated_at":"2016-09-22T23:36:40Z","body":"> I'd think (and hope) that the WP REST API would ideally support (out of box) all of the default WP Query params, shouldn't it?\r\n\r\nNot necessarily; we have support for the majority of them, but `filter` is intentionally available as an escape hatch to access the underlying query parameters if you want to. In this case, this is a significantly advanced use case that may benefit from a custom endpoint, so we only support it via the escape hatch. :)"}}
{"actor":{"display_login":"rmccue"}}