$menu_items = wp_get_nav_menu_items('MenuName');
echo '<ul>';
foreach($menu_items as $key => $val){
if($menu_items[$key]->menu_item_parent == 0){
echo '<li>';
echo $menu_items[$key]->title;
$submenuitem = get_nav_menu_item_children($menu_items[$key]->ID, $menu_items);
if(!empty($submenuitem)){
echo '<ul>';
foreach($submenuitem as $skey => $sval){
echo '<li id="post-'.$submenuitem[$skey]->object_id.'">';
echo $submenuitem[$skey]->title;
echo '</li>';
}
echo '</ul>';
}
echo '</li>';
}
}
echo '</ul>';
No comments:
Post a Comment