Answers:
从相同的功能中获取:
// prior to wordpress 4.5.0
$args = array(
'number' => $number,
'orderby' => $orderby,
'order' => $order,
'hide_empty' => $hide_empty,
'include' => $ids
);
$product_categories = get_terms( 'product_cat', $args );
// since wordpress 4.5.0
$args = array(
'taxonomy' => "product_cat",
'number' => $number,
'orderby' => $orderby,
'order' => $order,
'hide_empty' => $hide_empty,
'include' => $ids
);
$product_categories = get_terms($args);
将为您提供产品类别列表。简单!
foreach( $product_categories as $cat ) { echo $cat->name; }