i'm trying to filter through acf fields in wordpress Blocks. I have a couple of select components fetching all my posts and filtering them based on their acf fields. It's working pretty well except for one field. It's a relation one in ACF and it generate an array.
In my REST route, for every post, i did see it like that :
"acf": {
"api_id": "31",
"capacity": "30",
"api_array": [1795]
}
I expose my fields like this in my php :
add_filter( 'rest_rooms_query', function( $args, $request ){
if ( $meta_key = $request->get_param( 'metaKey' ) ) {
$args['meta_key'] = $meta_key;
$args['meta_value'] = $request->get_param( 'metaValue' );
}
return $args;
}, 10, 2 );
In my block.json, i'm totally able to ask a query like that :
"attributes": {
"query": {
"type": "object",
"default": {
"perPage": -1,
"postType": "rooms",
"metaKey": "capacity",
"metaValue": "30"
}
}
},
And it's working just fine (in my edit.js i'm able to update all of it with my select values). But when it comes to do the same for my "api_array" field, nothing works! So if i try this, there's no way to make it work (i tried all the syntax possible for arrays, nothing is able to make it work) :
"attributes": {
"query": {
"type": "object",
"default": {
"perPage": -1,
"postType": "rooms",
"metaKey": "api_array",
"metaValue": [1795]
}
}
},
Did anybody have a clue of what's going on for this field?
Thanks a lot!