THanks so much for helping me!!
Code (same as yours with my element id)
add_filter( 'bricks/posts/query_vars', function( $query_vars, $settings, $element_id ) {
if ( $element_id === 'brxe-rmpcwq' && function_exists( 'get_field' ) ) {
$gallery = get_field( 'gallery' );
if ( empty( $gallery ) ) {
/* Make sure that no posts are returned when
* there are no images in the gallery
*/
$query_vars['post__in'] = [0];
return $query_vars;
}
/* Get the first gallery item to automatically determine
* the ACF gallery field's return format
*/
$test_item = current( $gallery );
if ( is_array( $test_item ) ) {
// Get image IDs from image arrays
$gallery = array_map( function( $image_array ) {
return $image_array['ID'];
}, $gallery );
} else if ( is_string( $test_item ) ) {
// Try to get image IDs from image urls
$gallery = array_map( function( $image_url ) {
return attachment_url_to_postid( $image_url );
}, $gallery );
}
$query_vars['post__in'] = $gallery;
}
return $query_vars;
}, 10, 3 );
I have a template(registered as Section) with query Loop
Query
Elements
Acf fields
Acf rules
Thank you so much!!



