我有这个代码,但它显示了所有的类别,其中有产品添加到它。我只需要使用下面的代码按ID显示某些类别。
<span class="top"><h2>TOP CATEGORIES</h2></span>
<?php
$prod_categories = get_terms( 'product_cat', array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 1
));
foreach( $prod_categories as $prod_cat ) :
$cat_thumb_id = get_woocommerce_term_meta( $prod_cat->term_id, 'thumbnail_id', true );
$cat_thumb_url = wp_get_attachment_thumb_url( $cat_thumb_id );
$term_link = get_term_link( $prod_cat, 'product_cat' );
?>
<div class="catimg">
<a href="<?php echo $term_link; ?>">
<img src="<?php echo $cat_thumb_url; ?>" alt="<?php echo $prod_cat->name; ?>" />
</a>
<br/>
<?php echo $prod_cat->name; ?>
</div>
<?php endforeach; wp_reset_query(); ?>
$prod_categories = get_terms( 'product_cat', array(
'orderby' => 'name',
'include' => array(IDs HERE),
'order' => 'ASC',
'hide_empty' => 1
));