我试过:
<?php
$args = array(
\'type\' => \'product\',
\'child_of\' => 0,
\'parent\' => \'\',
\'orderby\' => \'term_group\',
\'hide_empty\' => false,
\'hierarchical\' => 1,
\'exclude\' => \'\',
\'include\' => \'\',
\'number\' => \'\',
\'taxonomy\' => \'product_cat\',
\'pad_counts\' => false
);
$cats = get_categories( $args );
//var_dump($cat);
foreach( $cats as $cat ){
echo $cat->name.\', \';
}
?>
它将打印按层次结构分组的所有类别,在我的示例中:
Events, Sport, Music, Culture, Workshop, Tourism, Football, Rugby, Tennis.
我只想省略没有被选入该职位的类别。