woocommerce_subcategory_thumbnail() Hook question
-
So I read the post on the hook woocommerce_subcategory_thumbnail()
doesn’t work with the plugin.I have a code something like this below. to get the child category from the current category archive page.
$parentid = get_queried_object_id(); $args = array( 'parent' => $parentid ); $terms = get_terms( 'product_cat', $args ); if ( $terms ) { echo '<ul class="product-cat-items">'; foreach ( $terms as $term ) { echo '<li class="product-cat-item">'; woocommerce_subcategory_thumbnail( $term ); echo $term->name; echo '</li>'; } echo '</ul>'; }
The above code does not work
Then I change it to the below code And it doesn’t work either.$parentid = get_queried_object_id(); $args = array( 'parent' => $parentid ); $terms = get_terms( 'product_cat', $args ); if ( $terms ) { echo '<ul class="product-cat-items">'; foreach ( $terms as $term ) { $size = 'thumbnail'; $thumbnail_id = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', $size ); $image = wp_get_attachment_url( $thumbnail_id ); echo '<li class="product-cat-item">'; echo '<img src="'. $image . '">'; echo $term->name; echo '</li>'; } echo '</ul>'; }
Any idea how it may work?
Thanks
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘woocommerce_subcategory_thumbnail() Hook question’ is closed to new replies.