April 25, 2018
I use this fairly often. I find working with plugins I already have installed is better than installing additional plugins to resolve the issue I’m trying to accomplish more reliable.
<ul class="blog_icons"> <?php $categories = get_the_terms( get_the_ID(), 'category' ); foreach( $categories as $category ) { // echo $category->term_id . ', ' . $category->slug . ', ' . $category->name . '<br />'; $image = get_field('icon', $category) ?> <li><a href="<?php bloginfo('url'); ?>/category/<?php echo $category->slug; ?>"><img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /></a></li> <?php } ?> </ul>