So I’m trying to use jQuery to make requests to a REST API (wordpress). Due to encoding this:
http://localhost:8040/?rest_route=/wp/v2/posts&filter[meta_key]=holiday_type&filter[meta_value]=villa
becomes this:
http://localhost:8040/?rest_route=%2Fwp%2Fv2%2Fposts&filter%5Bmeta_key%5D=holiday_type&filter%5Bmeta_value%5D=villa&
Thus resulting in wrong results. Is there a setting I could change or a I can override to handle. If so, which controller should I extend? The documentation is not that exhaustive
Edit
This is how I prepare the request:
$.get('/', {
'rest_route': '/wp/v2/posts',
'filter[meta_key]': 'holiday_type',
'filter[meta_value]': holidayType
}).done(function(data) {
// do processing
})
I found the solution. Wordpress already decodes urls automatically. I discovered however that the filter query var was removed as of wordpress 4.7 with the implementation of WP API v2. So I just need this snippet of code to my
functions.php
file and it worked.