WP REST API: Order posts by meta value (acf)?

Question

I’m requesting posts with the WP REST API and need to sort them according to an ACF field. It’s value represents a date (numeric, jQuery date format yymmdd). I know how to do it with a normal WP_Query and tried to do the same using the rest api:

mydomain.com/wp-json/wp/v2/posts?filter[orderby]=meta_value_num&filter[meta_key]=my_field_name&filter[order]=DESC

In fact I’m using a custom post type that’s registered with the rest api and everything else is working perfectly, so I think its not a cpt specific issue?

But the posts show up in default order (their creation date, latest to oldest). What am I missing? Is this orderby parameter not supported by the rest api? If so, how can I implement it myself?

Any other workarounds, suggestions? Really looking for a solution! Thankful for any hints!

0
Mauro Bringolf 4 months 0 Answers 20 views 0

Leave an answer