'', 'slug' => '', 'menu_class' => 'menu', 'format' => 'div', 'fallback_cb' => 'wp_page_menu', 'echo' => true, 'link_before' => '', 'link_after' => '' ); $args = wp_parse_args( $args, $defaults ); $args = (object) $args; // Get the menu $menu = null; if ( !empty($args->id) ) { $menu = wp_get_nav_menu( $args->id ); } elseif ( !empty($args->slug) ) { $menu = get_term_by( 'slug', $args->slug, 'nav_menu' ); } else { $menus = wp_get_nav_menus(); foreach ( $menus as $menu_maybe ) { if ( wp_get_nav_menu_items($menu_maybe->term_id) ) { $menu = $menu_maybe; break; } } } // If the menu doesn't exists, call the fallback_cb if ( !$menu || is_wp_error($menu) ) return call_user_func($args->fallback_cb, $args ); if ( 'div' == $args->format ) echo '
'; } function wp_print_nav_menu( $args = array() ) { // Defaults $defaults = array( 'type' => 'frontend', 'name' => 'Menu 1', 'id' => 0, 'desc' => 2, 'before_title' => '', 'after_title' => ''); $args = wp_parse_args($args, $defaults); extract($args, EXTR_SKIP); $menu_items = wp_get_nav_menu_items( $id ); $parent_stack = array(); $current_parent = 0; $parent_menu_order = array(); // Setup parentage foreach ( $menu_items as $menu_item ) { $parent_menu_order[ $menu_item->ID ] = $menu_item->menu_order; } // Display Loop foreach ( $menu_items as $key => $menu_item ) { $menu_item = wp_setup_nav_menu_item($menu_item); // List Items ?>