In my custom wordpress theme I currently have the below loop to the main categories
<?php
$menu = wp_get_nav_menu_object('navigation');
$items = wp_get_nav_menu_items($menu->term_id);
foreach($items as $item)
{
?>
<li><a href="<?php echo $item->url ?>"><?php echo $item->title ?></a></li>
<?php
}
?>
So it'll just list out each like so:
- Cat A
- Cat B
- Cat C
- Cat D
But I have now added some subcategories under Cat B
so I would like to have it as so:
- Cat A
- Cat B
- Cat B 1
- Cat B 2
- Cat C
- Cat D
I know what to do regarding the html markup but what php command do I use in the loop to distinguish the subcategories?
wp_nav_menu
and let it handle the hierarchical output for you?