I use this code in PHP:
$idcat = 147;
$thumbnail_id = get_woocommerce_term_meta( $idcat, 'thumbnail_id', true );
$image = wp_get_attachment_url( $thumbnail_id );
echo '<img src="'.$image.'" alt="" width="762" height="365" />';
Where 147
is the current ID manually set, but i need to current id in other categories
Any suggest?
Add code in
/wp-content/plugins/woocommerce/templates/
loop pathFrom the WooCommerce page:
You may also used foreach loop for display category image and etc from parent category given by parent id.
for example, i am giving 74 id of parent category, then i will display the image from child category and its slug also.
To display the category image for the currently displayed category in
archive-product.php
, use the current categoryterm_id
whenis_product_category()
is true:To prevent full size category images slowing page down, you can use smaller images with
wp_get_attachment_image_src()
:EDIT: Fixed variable name and missing quote