At first glance, and without testing anything, the code you’ve got should work but I expect that you have a number of spurious </ul>
in your markup. You need to do nearly the same thing for the end_lvl
method.
function end_lvl(&$output, $depth) {
if($depth >= 2) {
$output .= '';
} else {
$output .= "</ul>";
}
}
I don’t know if that is the problem with your megamenu or not.
Related Posts:
- Custom menu walker: how can i check first item
- How to exclude/remove submenu using Walker_Nav_Menu
- Display only page specific sub menu items using Custom Walker
- Add class to top level menu item if it has multiple child levels
- How to add a child item to a menu element (using wp_nav_menu_objects)
- Simple Navigation Walker – Wrapper-class around first sub-menu
- Primary and secondary menus
- how to get custom admin submenu( custom post type ) item to highlight when its active
- Custom Nav Walker sub-menu HTML construct
- Check if wp_nav_menu items have submenus
- Add div to specific sub-menu
- Nav walker, bootstrap: Display 3rd level items under 2nd level
- Sub-Pages only of menu items in current branch using a custom menu
- Custom Nav Walker to show siblings and children of current branch?
- How to display dynamic content in start_lvl function
- Create self-populating menu and add extra divs to the menu layout
- How to add a submenu toggle button inside all “li” elements that have a submenu?
- Main Menu and Sub Menu Items for Footer
- How to construct a custom html for submenus
- WordPress bootstrap menue with 3. level
- Subnav menu – adapt to show the same on parent, child & grandchildren pages?
- How to add ID attribute to each submenu?
- disable menu collapse/expand function and make a menu item a static, unclickable text
- Custom Nav Walker sub-menu
- Submenu causes issue in defined blog page
- Define supporting only 1-level menu
- Change submenu markup
- getting the current sub item out of total sub items in a given dropdown (custom walker)
- Custom megameu walker need improvement
- Get the page IDs of a Particular Menu item’s submenu
- sub-menu does not show on the very top bar
- How to Add support for sub-menu item description in wordpress?
- How to hide Newsletter plugin submenus from the Dashboard?
- WordPress custom menu can’t show 3. level submenu
- Links doesnt appear as a submenu on a mobile
- How can I creat custom menu with bootstrap
- Notices are render inside sub-menu’s content
- Problem add submenu page
- Menu walker: how to tell if a sub menu contains submenus?
- Where to place a svg chevron down in my custom walker?
- Controlling the position of dropdow submenu
- Custom Walker menu depth opening problem
- Assign index page to my mobile site?
- Displaying a part of a menu containing the page the user is currently viewing and only it’s immediate children
- Restrict days in bootstrap datepicker using checkboxes in submenu
- WordPress menu walker – Get parent item text inside end_lvl function
- Need help finding information to create this type of page
- Conditional Nav Menu Inside Nav Menu Across Multisite Sites
- Trouble posting in Sub-Category
- Subpages List Appearing on Every Page
- Active class on side menu
- I need to get this sub nav to show up on cat, sup-cat and post
- Show menu on page with all sub-pages and sub-sub-pages of that page
- WordPress two row automatic sub navigation with double wp_list_pages. Is it impossible?
- Horizontal sub-menu on one line
- Nav walker bootstrap: Display 3rd level and 4th level in dropdown menu
- Display a portion/ branch of the menu tree using wp_nav_menu()
- Menu items description? Custom Walker for wp_nav_menu()
- Is It Possible To Add Custom Post Type Menu As Another Custom Post Type Sub Menu
- Custom Walker: how to get ID in function start_lvl
- Split up wp_nav_menu with custom walker
- Custom Nav walker display current menu item children, or siblings on no children
- How to add sub-menu to a menu generated by wp_nav_menu by using plugin
- Remove Categories / Tags From Admin Menu
- Add a custom walker to a menu created in a widget
- Using a menu walker add a custom item at the end of the menu’s items
- WordPress API Menu/Submenu Order
- Error “Trying to get property of non-object” with Custom Walker for wp_nav_menu
- Mega Menu Walker
- Add an admin page, but don’t show it on the admin menu
- Getting custom admin submenu item to highlight when its active
- How to count nav menu items?
- How Does The Walker Class Work?
- Add custom menu item using wp_nav_menu_items filter
- start_lvl Ignored in Custom walker_nav_menu
- What is a good resource to find out about making custom walkers?
- Does Extending Multiple Nav_Menu_Walkers Allow Nested Menus?
- Add Caret to Menu Items with Sub-Menus in WordPress Theme
- how to create a menu with all sub categories?
- Comment Walker vs. Comment Callback
- Remove a menu item created by a plugin
- How does a minimal menu walker look like?
- Add separator to admin submenu
- How do I dynamically populate wp_nav_menu from a custom taxonomy?
- Assign posts to taxonomy terms instead of the taxonomy terms to posts?
- Strict Standards Error bootstrap navwalker
- Add custom html to last sub-menu item
- WordPress Menu Custom Walker Class
- How to create this custom menu walker?
- WordPress 4.4+ breaks Walker Extension
- Call custom field into menu item
- add span class inside wp_nav_menu link anchor tag
- Add a .last class to the last in each ul.sub-menu
- Order Admin sub-menu items?
- How Can I remove or hide the export page in WordPress menu?
- Get page by template?
- Multi Level Bootstrap Navigation Menu in WordPress
- Determine if a navigation item has children
- How show sub menu only using wp_nav_menu()
- List Hierarchical Term List with Count with Related Term