Output wp_nav_menu
-
Hi The following function outputs a menu that has been selected on a per page basis. However, I’d like the menu to include the WP default wp_nav_menu instead of just an unordered list. Ie. I’d like the current
<li>
to inherit the current-menu-item class when the current page is selected. How do I do this?function sidebar_get_all_menus() { $menu_obj = get_terms( 'nav_menu' ); return $menu_obj; } function sidebar_generate_menu_from_items($items) { if(count($items)>0): $menu_list = '<ul id="menu-' . $menu_to_use . '">'; foreach ( (array) $items as $key => $menu_item ) { $title = $menu_item->title; $url = $menu_item->url; $menu_list .= '<li class="' . $class . '"><a href="' . $url . '">' . $title . '</a></li>'; } $menu_list .= '</ul>'; return $menu_list; endif; }
Thanks!
- The topic ‘Output wp_nav_menu’ is closed to new replies.