To get category image url based on category ID use the fallowing:
// verify that this is a product category page
if ( is_product_category() ){
global $wp_query;
// get the query object
$cat = $wp_query->get_queried_object();
// get the thumbnail id using the queried category term_id
$thumbnail_id = get_term_meta( $cat->term_id, 'thumbnail_id', true );
// get the image URL
$image = wp_get_attachment_url( $thumbnail_id );
// print the IMG HTML
echo "<img src='{$image}' alt='' width='762' height='365' />";
}
When placing a url in to css make sure not to put aditional quotes in background-image: url()
as it will brake the link – striping slashes.
If you like to get image instead, you can use:
wp_get_attachment_image($image->ID)
https://stackoverflow.com/questions/12717112/how-to-display-woocommerce-category-image