I’m building an AJAX filtering system and am trying to include a filter that can take multiple IDs and then filter custom post type posts based on its relationship field. Is there any handy method of doing meta_query with an array of values for a relationship field which is saved as array? I’m trying to achieve something like this
‘meta_query’ => array(
array(
‘key’ => ‘relationship_field’,
‘value’ => serialize([1234, 4321]),
‘compare’ => ‘LIKE’,
)
)
Is anything like this doable or is doing multiple OR conditioned meta queries the only option? This probably gets pretty heavy very quickly, so is there best practice on how many you should use, meaning I could probably limit how many IDs can be passed to the filtering function?
It’s possible to filter out posts that don’t match inside the loop with array_intersect IF statement, but that wouldn’t be very good for pagination.
The only way to do this is with multiple meta OR queries for each related post ID