Get Woocommerce Category Thumbnails Get Woocommerce Category Thumbnails wordpress wordpress

Get Woocommerce Category Thumbnails


Sorted it, here's the code I used:

$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );$image = wp_get_attachment_url( $thumbnail_id );


If the get_woocommerce_term_meta() function does not work for you then you can try the get_term_meta()function instead.

You can get the WooCommerce product category thumbnail with the following code-

<?php$thumbnail_id = get_term_meta( $cat->term_id, 'thumbnail_id', true );$image_url = wp_get_attachment_url( $thumbnail_id ); // This variable is returing the product category thumbnail image URL.


Had a similar setup but when I used what you did I didnt actually get the thumbnail file I got the full image file so instead I used this: wp_get_attachment_thumb_url so that my output url would be "../my-images"/image-150x150.jpg" and actually got it to pull the thumbnail image, just incase anyone runs into a similar situation..