在WooCommerce中,我想将商店中的所有类别显示为标题,并将其所有产品列在下面的无序列表中。这可能吗?我看到了一些可以让我显示类别列表或特定类别的产品列表的东西,但没有任何东西可以像我描述的那样循环遍历所有内容。
以下是我目前用于列出所有类别的内容:
<?php
$args = array(
\'number\' => $number,
\'orderby\' => $orderby,
\'order\' => $order,
\'hide_empty\' => $hide_empty,
\'include\' => $ids
);
$product_categories = get_terms( \'product_cat\', $args );
$count = count($product_categories);
if ( $count > 0 ){
foreach ( $product_categories as $product_category ) {
echo \'<h4><a href="\' . get_term_link( $product_category ) . \'">\' . $product_category->name . \'</h4>\';
}
}
?>