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!
© 2023 Advanced Custom Fields.