Need help generating a category link
-
This code outputs a category image and title. I need them to link to individual category pages. I’ve tried the_permalink and get_category_link but neither worked for me.
<?php $catTerms = get_terms('product_cat', array('hide_empty' => 0, 'orderby' => 'ASC', 'child_of'=>'7')); foreach($catTerms as $catTerm) : ?> <?php $thumbnail_id = get_woocommerce_term_meta( $catTerm->term_id, 'thumbnail_id', true ); // get the image URL $image = wp_get_attachment_url( $thumbnail_id ); ?> <div class="col-md-4 col-xs-2"> <a href="<?php the_permalink(); ?>"><img src="<?php echo $image; ?>" width="100%" /></a> <h4 class="prod-title"><?php echo $catTerm->name; ?></h4> </div> </div> <?php endforeach; ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Need help generating a category link’ is closed to new replies.