results 1 - 1 of about 1 for Show Woocommerce parent product categories with images. (0,149 seconds) 

Show Woocommerce parent product categories with images

<?php
 /*Loop av hoved produktkategorier*/
 $catTerms = get_terms('product_cat', array('hide_empty' => 0, 'orderby' => 'ASC', 'parent' => 0));
 foreach($catTerms as $catTerm) {
 echo "<div class="box">";
 $thumbnail_id = get_woocommerce_term_meta( $catTerm->term_id, 'thumbnail_id', true );
 $image_res = wp_get_attachment_image_src( $thumbnail_id, 'shop_catalog' );
 echo "<a href="/?product_cat=" . $catTerm->slug . ""><img src="$image_res[0]" alt="" style="width:240px;height:auto;" /></a>";
 echo "<h4 class="" . $catTerm->slug . "">" . $catTerm->name . "</h4>";
 echo "</div>";
 }
 ?>

Tags: , ,


Comments are closed.