ulphp$parent_categories = get_categoriesarray parent = 0 hide_empty = false Set to true to hide empty categories;foreach $parent_categories as $category liaspanphp echo $category-name; spanalip
-
0,
'hide_empty' => false // Set to true to hide empty categories
));
foreach ($parent_categories as $category) { $child_categories = get_categories(array( 'parent' => $category->term_id, 'hide_empty' => false )); ?>
<li <?php if (!empty($child_categories)) { echo 'class="has-children"'; } ?>>
<a><span><?php echo $category->name; ?></span></a>
<?php if (!empty($child_categories)) { ?>
<ul class="children">
<?php foreach ($child_categories as $child_category) { ?>
<li><a><span><?php echo $child_category->name; ?></span></a></li>
<?php } ?>
</ul>
<?php } ?>
</li>
原文地址: https://www.cveoy.top/t/topic/i34t 著作权归作者所有。请勿转载和采集!