<ul>
<?php
$taxonomyName = "product_cat";
$prod_categories = get_terms($taxonomyName, array(
\'orderby\'=> \'name\',
\'order\' => \'Desc\',
\'hide_empty\' => 1,
));
foreach( $prod_categories as $prod_cat ) :
if ( $prod_cat->parent != 0 )
continue;
$cat_thumb_id = get_woocommerce_term_meta( $prod_cat->term_id, \'thumbnail_id\', true );
$cat_thumb_url = wp_get_attachment_image_src( $cat_thumb_id, \'thumbnail-size\' )[0];
$term_link = get_term_link( $prod_cat, \'product_cat\' );
?>
<李>
<h2>02</h2>
<h3><div class="cat"><div class="wrap_cat"><?php echo $prod_cat->name; ?> </div></div></h3>
</span>
<img src="<?php echo $cat_thumb_url; ?>" alt=""/>
<p><?php ?></p>
<a href="<?php echo $term_link; ?>" class="trend_read_more"> Read More</a>
</li> <?php endforeach;
wp_reset_query(); ?>
</ul>
我想在p标签内显示类别描述,如果有人知道,请帮助我?
最合适的回答,由SO网友:eldoleo 整理而成
$args = array( \'taxonomy\' => \'product_cat\' );
$terms = get_terms(\'product_cat\', $args);
$count = count($terms);
if ($count > 0) {
foreach ($terms as $term) {
echo $term->description;
}
}