Sorting results from JSON-API on custom fields

Is there any way, out of the box, to sort results from the JSON-API plugin based on values in custom fields? The request is paged, so the results will need to be sorted server-side.

I have an http request along the lines of:

http://www.example.com/wordpress/?json=get_author_posts&author_slug=user&post_type=custom
&include=title,custom_fields&custom_fields=date_value&count=10&page=1

I’d like to sort on the custom field date_value, ideally without having to create a new controller within the json plugin. Is this possible?

3 Answers
3

Looking through the source code, this plugin maps the query variable orderby to the WP_Query argument of the same name, orderby.

What this means is that you should be able to do the following:
http://www.example.com/wordpress/?json=get_author_posts&author_slug=user&post_type=custom&include=title,custom_fields&custom_fields=date_value&count=10&page=1&orderby=date_value

Leave a Comment