Home › Forums › General Issues › Taxonomy Term Image › Reply To: Taxonomy Term Image
I’ve now got it working with the following code:
<?php
$terms = get_the_terms( get_the_ID(), 'product_brands' );
if( ! empty( $terms ) ) : ?>
<ul>
<?php foreach( $terms as $term ) : ?>
<li class="<?php echo $term->slug; ?>">
<img src="<?php the_field('brand_logo', $term); ?>" />
</li>
<?php endforeach; ?>
</ul>
<?php
endif;
?>
I had to change the taxonomy name from brands to product_brands because I was already using a brands taxonomy for another CPT. However, this wasn’t the cause of the images not displaying, the only thing that was missing before was wrapping the <?php the_field(‘brand_logo’, $term); ?> in an image tag, seems obvious now.
Are there any issues doing it this way?.
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.