{"action":"created","issue":{"url":"https://api.github.com/repos/WP-API/WP-API/issues/2926","repository_url":"https://api.github.com/repos/WP-API/WP-API","labels_url":"https://api.github.com/repos/WP-API/WP-API/issues/2926/labels{/name}","comments_url":"https://api.github.com/repos/WP-API/WP-API/issues/2926/comments","events_url":"https://api.github.com/repos/WP-API/WP-API/issues/2926/events","html_url":"https://github.com/WP-API/WP-API/issues/2926","id":191678203,"number":2926,"title":"Allow random orderby in post queries","user":{"login":"jeherve","id":426388,"avatar_url":"https://avatars.githubusercontent.com/u/426388?v=3","gravatar_id":"","url":"https://api.github.com/users/jeherve","html_url":"https://github.com/jeherve","followers_url":"https://api.github.com/users/jeherve/followers","following_url":"https://api.github.com/users/jeherve/following{/other_user}","gists_url":"https://api.github.com/users/jeherve/gists{/gist_id}","starred_url":"https://api.github.com/users/jeherve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeherve/subscriptions","organizations_url":"https://api.github.com/users/jeherve/orgs","repos_url":"https://api.github.com/users/jeherve/repos","events_url":"https://api.github.com/users/jeherve/events{/privacy}","received_events_url":"https://api.github.com/users/jeherve/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-11-25T11:08:25Z","updated_at":"2016-11-27T10:36:24Z","closed_at":"2016-11-27T10:36:24Z","body":"I'm having some trouble querying a list of random posts with the most recent version of the WP REST API.\r\n\r\nUp until last month, one could use `rand` with the `orderby` [WP Query parameter][1] to retrieve posts in a random order, like so:\r\n\r\n`/wp-json/wp/v2/posts?filter[orderby]=rand`\r\n\r\nHowever, we recently got rid of that `filter` key structure in #2799. The request above would now look like this:\r\n\r\n`wp-json/wp/v2/posts?orderby=rand`\r\n\r\nThat request won't return random posts, though:\r\n\r\n```json\r\n{\r\n    \"code\":\"rest_invalid_param\",\r\n    \"message\":\"Invalid parameter(s): orderby\",\r\n    \"data\":{\r\n        \"status\":400,\r\n        \"params\":{\r\n            \"orderby\":\"orderby is not one of date, relevance, id, include, title, slug.\"\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nThat's because the list of supported query options in the WP REST API isn't the same as for regular WP queries. Only 6 query args are allowed [here][2].\r\n\r\nI looked for a filter allowing me to alter the list of allowed query arguments, but I couldn't find anything. I know we have `rest_query_vars` to edit the list of query vars, but I didn't find anything equivalent for query args.\r\n\r\nI know I could alter the whole query and force `rand` with the `rest_post_query` filter, but that's not what I'm looking for here.\r\n\r\nAm I missing something obvious here?\r\n\r\nThank you!\r\n\r\nRelated: #2906\r\n\r\n  [1]: https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters\r\n  [2]: https://github.com/WP-API/WP-API/blob/develop/lib/endpoints/class-wp-rest-posts-controller.php#L1866-L1882"},"comment":{"url":"https://api.github.com/repos/WP-API/WP-API/issues/comments/263114652","html_url":"https://github.com/WP-API/WP-API/issues/2926#issuecomment-263114652","issue_url":"https://api.github.com/repos/WP-API/WP-API/issues/2926","id":263114652,"user":{"login":"jeherve","id":426388,"avatar_url":"https://avatars.githubusercontent.com/u/426388?v=3","gravatar_id":"","url":"https://api.github.com/users/jeherve","html_url":"https://github.com/jeherve","followers_url":"https://api.github.com/users/jeherve/followers","following_url":"https://api.github.com/users/jeherve/following{/other_user}","gists_url":"https://api.github.com/users/jeherve/gists{/gist_id}","starred_url":"https://api.github.com/users/jeherve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeherve/subscriptions","organizations_url":"https://api.github.com/users/jeherve/orgs","repos_url":"https://api.github.com/users/jeherve/repos","events_url":"https://api.github.com/users/jeherve/events{/privacy}","received_events_url":"https://api.github.com/users/jeherve/received_events","type":"User","site_admin":false},"created_at":"2016-11-27T10:36:24Z","updated_at":"2016-11-27T10:36:24Z","body":"👍 Closing in favor of https://core.trac.wordpress.org/ticket/38693"}}
{"actor":{"display_login":"jeherve"}}