Home › Forums › General Issues › Query taxonomy for fields › Reply To: Query taxonomy for fields
Are you sure there is an image field called “icon” on each of your terms?
Yes, there’s.
What have you set as the return value of this field? With your current code it should be set to “image object”.
Yes, it’s
There’s attachment of my settings.
Also, you’re currently echoing the image outside of the li tag which I don’t think is what you want.. ?
I know. It should be like:
<?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', $term->taxonomy . '_' . $term->term_id);
$image_thumb = $icon['sizes']['full'];
?>
<li>
<h3><a href="<?php echo get_term_link( $term->name, $term->taxonomy ); ?>"><?php echo $term->name; ?></a></h3>
<img src="<?php echo $image_thumb; ?>" class="icona" alt="" />
</li>
<?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.