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
- Add custom menu item using wp_nav_menu_items filter
- How show sub menu only using wp_nav_menu()
- Reorder custom submenu item
- Custom Nav Walker menu – Display children count
- Adding Post Counts to Menu (Nav) Programmatically?
- Show top-level parent with submenu menu walker
- Bar separated navigation by extending Walker_Nav_Menu
- wp_nav_menu custom walker – child items
- Logout hyperlink within a sub-menu
- Show menu based on parent & ancestor
- Remove All in One Pack from the admin bar
- custom walker wp menu last element
- Remove unwanted elements for a wp_nav_menu
- WordPress Quick Question . How to Get Parent Link in Submenu in My Code
- Sub menu indicator that links to sub menu
- Custom navigation structure with walker class
- Custom Navigation build using wp_nav_menu and walker
- Troubles with Walker_Nav_Menu and closing
- Using parent slug variable to display proper submenu not working properly
- WordPress Remove Submenus
- Help with walker for nav
- Why is only the first operation run in my loop – except for on the last repeat? [closed]
- How can I apply filters in my class that extends Walker_Nav_Menu?
- Displaying Nav Menu
- Adding toggle-able element after menu item
- URL links consistent with menus?
- WordPress Custom Menu Admin helper plugin
- Top Nav submenus wpon’t stay open – only in FF and only sometimes [closed]
- changing the labels inside appearance -> menus for some for the fields
- Controlling sub-menu within sub-menu
- Custom menu with additional logic for display
- hide page menu from admin panel for specific users
- Submenu Page under Settings in Admin Panel
- Walker_Category – not reliably saving
- Add href to tag in nav menu for mobile
- wp_nav_menu prints children with parent name
- edit-tags.php in plugin admin menu hides when is the active page
- Help with output of post classes using apply_filters
- Override edit_custom_walker.php to conditionally show input depending on menu position
- Use menu structure for permalinks
- Main Menu Theme Different Output Print
- Getting the top level permalink using get_post_ancestors()
- How to add drop down sub menu from database fields in the particular menu slug
- Submenu opened problem
- Should I custom code drop down menus or use a wordpress plugin?