Custom Taxonomy list with Images using ACF

<div class="projCatWrapper">
	<div class="row">
		<?php 
		$tax = 'project_category';
		$terms = get_terms( $tax, $args = array(
			'hide_empty' => false, // do not hide empty terms
		));
		foreach( $terms as $term ) {
			$term_link = get_term_link( $term );
				$image = get_field('category_thumbnail',  'project_category_' . $term->term_id );
			if( $term->count > 0 ) {
				echo '<div class="col-sm-4 col-xs-12 projCol"><div class="projCatItem"><a href="' . esc_url( $term_link ) . '">';
				echo '<img src="' . $image['url'] . '" alt="' . $image['alt'] .'"><div class="projCatName"><span>';       
				echo $term->name .'</span></a></div></div></div>';
			} elseif( $term->count !== 0 ) {
				echo '' . $term->name .'';
			}
		}
		?>
	</div>
</div>

Leave a Reply

Your email address will not be published. Required fields are marked *