I need query custom posts with ACT Taxonomy field. I created this code:
My Taxonomy ACF field returns Term Object and allows multiselect but this code works only for last selected term. I need query all selected terms.
<?php
$album_count = get_sub_field('album-count');
$album = get_sub_field('album-custom-category'); ?>
<?php foreach ( $album as $album ); ?>
<?php $the_query = new WP_Query(
array(
'post_type' => 'gallery',
'orderby' => 'date',
'posts_per_page' => 6,
'tax_query' => array(
array(
'taxonomy' => 'albums',
'field' => 'slug',
'terms' => array( $album->slug ),
),
),
)
);
?>
Where is my mistake?