wordpress: Display custom post types custom taxonomy terms and link to archive page
<?php
$args = array(
'post_type' => 'product',
'order' => 'ASC',
);
$query = new WP_Query( $args );
?>
<?php if($query->have_posts()) : ?>
<?php while($query->have_posts()) : $query->the_post() ?>
<?php foreach (get_the_terms(get_the_ID(), 'product_types') as $cat) : ?>
<div class="product">
<img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" />
<a class="product-link" href="<?php echo get_term_link($cat->term_id, 'product_types'); ?>"><?php echo $cat->name; ?></a>
</div>
<?php endforeach; ?>
<?php endwhile ?>
<?php endif ?>
<?php wp_reset_postdata(); ?>