[ad_1]
Hi @charlie67p,
You cannot do that functionality in CBB, but it provides a custom hook that allows you to adjust any query loop. Here is how to do it:
add_filter( 'cbb_query_loop_block_query_vars', function ( $query_vars, $default_vars, $cbb_params, $query_context, $query_object ) {
// Add code to check if this is the query to alter and on the frontend.
if ( 'filter_places' === ( $cbb_params['metaQuery']['queries'][0]['key'] ?? '' ) && $query_object && $query_object->ID ) {
// Clear the fake filter_places meta.
unset($query_vars['meta_query']);
$query_vars['meta_key'] = 'place_id';
$query_vars['meta_value'] = (array)get_field( 'place_id', $query_object->ID );
$query_vars['meta_compare'] = 'IN';
}
return $query_vars;
}, 10, 5);In your query loop, add a meta query with the key named filter_places and set the compare operator as EXISTS
You also need to set bidirectional relationship on your ACF post object field.
I have not tested it myself, but you can get the idea based on above code.
P/S: My other plugin MFB does exactly the same functionality as your case, but it is only available in the Pro version.
Please let me know if it works.
It works like a charm
Thank you – such a great plugin!
