Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

woocommerce_subcategory_thumbnail() Hook question

$
0
0

Replies: 0

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 all articles
Browse latest Browse all 59525

Trending Articles