If you want to run a query of child categories from a specific Parent category and pull it’s product category image.
<?php | |
$catTerms = get_terms('product_cat', array( | |
'hide_empty' => 0, | |
'orderby' => 'ASC', | |
'child_of'=>'33' // air sampling applications | |
)); | |
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="application blocks"> | |
<a href="#"> | |
<img src="<?php echo $image; ?>" /> | |
<?php echo $catTerm->name; ?> | |
</a> | |
</div><!-- applicaitons --> | |
<?php endforeach; ?> |
Hi Thanks for sharing this its nice but ca i get the only child categories only not grand child ex.
Shake (Main categories)
-Banana (Child categories)
–with ice cream (Grand Child categories)
–without ice cream (Grand Child categories)
-Mango (Child categories)
–with ice cream (Grand Child categories)
–without ice cream (Grand Child categories)
so here i want only child categories of main categories showing only 2 categories
Banana
Mango
so its possible plesae help