此代码仅显示类别,如何更改为同时包含子类别。ThanksThanks,用这段代码列出了所有内容,我想这样显示
第1类第1子类第2子类第1子类第3子类第2子类
<?php
$args = array(
\'taxonomy\' => \'product_cat\',
\'hide_empty\' => false,
);
$result = get_terms( $args );
?>
<ul class="list-unstyled">
<?php
foreach ( $result as $cat ) {
if ( \'Uncategorized\' !== $cat->name ) {
$term_link = get_term_link( $cat, \'product_cat\' );
$cat_thumb_id = get_woocommerce_term_meta( $cat->term_id, \'thumbnail_id\', true );
$shop_catalog_img_arr = wp_get_attachment_image_src( $cat_thumb_id, \'shop_catalog\' );
$cat_img = $shop_catalog_img_arr[0];
?>
<li><a href="<?php echo $term_link; ?>">
<?php echo $cat->name; ?>
</a></li>
<?php
}
}
?>
</ul>