Answer the question
In order to leave comments, you need to log in
How to get id of all subcategories in woocommerce archive?
Hello. I want to display the image of subcategories with the get_the_post_thumbnail() function in the content_product_cat.php file.
How to get id to specify it in function parameter?
Answer the question
In order to leave comments, you need to log in
Yes, you won’t be able to do this, it takes the id of the post, and you are in the
Use categorywp_get_attachment_image()
I was getting the category image on the archive page something like this
<?php
if ( is_product_category() ){
global $wp_query;
$cat = $wp_query->get_queried_object();
$thumbnail_id = get_term_meta( $cat->term_id, 'thumbnail_id', true );
$image = wp_get_attachment_url( $thumbnail_id );
if($image) {
echo '<div class="title-img"><img src="' . $image . '" alt="' . $cat->name . '" /></div>';
}
}
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question