A 帮助。我想显示特定父类别的子类别。例如
一个
-
机 管 局
-- AAA
-- AAA
-
BB
-- BBB
-- BBB
假设,以上是我的概念。现在我想显示父类别 (A( 中的所有"二级子类别(AAA、BBB("。不需要"AA和BB"类别。如果有人对此给出最佳解决方案?..
或者,请告诉我如何在此"&child_of=19"中添加多个类别???......
因为,现在我使用以下代码来显示子类别。
<?php
$subcategories = get_categories();
$subcategories = get_categories('&child_of=19&hide_empty&orderby=ID&order=DESC');
echo '<ul>';
foreach ($subcategories as $subcategory) {
echo sprintf('<li><a href="%s">%s</a></li>', get_category_link($subcategory->term_id), apply_filters('get_term', $subcategory->name));
}
echo '</ul>';
?>
尝试下面的代码
<?php
$subcategories = get_categories();
$subcategories = get_categories('&child_of=19&parent=19&hide_empty&orderby=ID&order=DESC');
echo '<ul>';
foreach ($subcategories as $subcategory) {
echo sprintf('<li><a href="%s">%s</a></li>', get_category_link($subcategory->term_id), apply_filters('get_term', $subcategory->name));
}
echo '</ul>';
?>