airesvsg / acf-to-rest-api

Exposes Advanced Custom Fields Endpoints in the WordPress REST API
https://wordpress.org/plugins/acf-to-rest-api/
1.33k stars 111 forks source link

filter[meta_compare] works incorrectly #284

Closed Defite closed 5 years ago

Defite commented 5 years ago

Hi, I have list of yachts with some tech specs. I want to filter them by yacht_passengers param. I have 0, 8, 34, 123 values for this field. Forgot to mention, yacht_passengers comes from ACF.

Suppose I have url like this:

http://localhost:5000/wp-json/wp/v2/yachts?filter[deal_types]=rent&filter[meta_key]=yacht_passengers&filter[meta_compare]=<&filter[meta_value]=10

Response will show all posts with yacht_passengers equal to 0, but not 8. If I change url like this:

http://localhost:5000/wp-json/wp/v2/yachts?filter[deal_types]=rent&filter[meta_key]=yacht_passengers&filter[meta_compare]=>&filter[meta_value]=10

I got posts with 8, 34 and 123. It's wrong, because 8 < 10, not opposite. Am I doing something wrong? yacht_passengers value is int, do I have to change it back to string? I've just tested it and both string and int modifications return wrong result.