Home › Forums › General Issues › Query taxonomy for fields › Reply To: Query taxonomy for fields
That’s because you fetch the image from the parent term.
Here’s a snippet that should work better for you:
<?php
$current_term = get_queried_object();
$args = array(
'parent' => $current_term->term_id,
'orderby' => 'slug',
'hide_empty' => false
);
$child_terms = get_terms( $current_term->taxonomy, $args );
?>
<ul>
<?php foreach ($child_terms as $term) { ?>
<?php
$icon = get_field('icon', $current_term->taxonomy . '_' . $current_term->term_id);
$image_thumb = $icon['sizes']['full'];
?>
<li><h3><a href="<?php echo get_term_link( $term->name, $current_term->taxonomy ); ?>"><?php echo $term->name; ?></h3></a></li>
<img src="<?php echo $image_thumb; ?>" class="icon" alt="" />
<?php } ?>
</ul>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.