Query Woocommerce Child Categories from specific parent ID

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; ?>

 

Leave a Reply

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

92 − 86 =