WooCommerce add images to category loop

I want to get my Category images into my WooCommerce loop below but the array that’s created from my code below doesn’t seem to collect the image URL.

PHP

Read More
<?php $catTerms = get_terms('product_cat', array('hide_empty' => 0, 'orderby' => 'ASC', 'exclude' => '17,77')); ?>

    <?php foreach($catTerms as $catTerm) : ?>
    <ul>
        <li><a href="<?php echo $catTerm->slug; ?>"><?php echo $catTerm->name; ?></a></li>
    </ul>
<?php endforeach; ?>

Would someone be kind enough to assist?

Thanks

Related posts

Leave a Reply

2 comments

  1. Try this,

    <?php $catTerms = get_terms('product_cat', array('hide_empty' => 0, 'orderby' => 'ASC', 'exclude' => '17,77')); ?>
    
        <?php foreach($catTerms as $catTerm) : 
               $wthumbnail_id = get_woocommerce_term_meta( $catTerm->term_id,'thumbnail_id', true );
               $wimage = wp_get_attachment_url( $wthumbnail_id );
        ?>
        <ul>
            <li><a href="<?php echo $catTerm->slug; ?>"><?php if($wimage!=""):?><img src="<?php echo $wimage?>"><?php endif;?><?php echo $catTerm->name; ?></a></li>
        </ul>
    <?php endforeach; ?>
    

    Hope its works..