Hi! I have a custom post type called “employees” with a taxonomy “department”. The field “department” is an acf taxonomy field in which i can select the departmens for the employees.
I select the employees i want to output in a repater field called(team) in which i select the posts through a post-object field. This solution is working perfectly for all the other acf fields but i just cant get the selected taxonomy values of each post. I always get all taxonomy slugs and not just the the slugs which i selected in the post.
<?php while ( have_rows('team') ) : the_row(); ?>
<?php
$post_object = get_sub_field('employee');
if( $post_object ):
$post = $post_object;
setup_postdata( $post );
?>
<?php $term = get_field('department'); ?>
<div class="all <?php foreach( $terms as $term ): ?><?php echo $term->slug; ?> <?php endforeach; ?> person">
<span class="name"><?php the_title(); ?></span>
</div>
<?php wp_reset_postdata(); ?>
<?php endif; ?>
<?php endwhile; ?>
var_dump($post_object) first of all, i guess you are not getting the args you expected using that code inside that loop.
Looks like your loop is broken;
You have $term = get_field(), then foreach( $terms as $term );
Should be
$terms = get_field('department');