Home › Forums › Front-end Issues › Get Custom Taxonomy Field Value › Reply To: Get Custom Taxonomy Field Value
This worked for me to get the taxonomy terms for the current post with an ACF icon field attached:
<?php $terms = get_the_terms( get_the_ID(), 'project_services' );
$cat_icon = get_field('icon', $queried_object);
?>
<?php if( $terms ): ?>
<ul class="menu">
<?php foreach( $terms as $term ): ?>
<li>
<a href="<?php echo get_term_link( $term ); ?>">
<?php $icon = get_field('icon', $term->taxonomy . '_' . $term->term_id);?>
<img src="<?php echo $icon ?>">
<?php echo $term->name; ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
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.