We can use depth parameter of wp_nav_menu to set how many levels menu walker traverses.
wp_nav_menu( array( 'menu_id'=>'nav', 'theme_location'=>'header-menu' , 'depth' => 1) );
You can create a child theme so that updates won’t override during updates.
Create child theme and copy code from header.php of parent theme then replace the code
wp_nav_menu( array( 'menu_id'=>'nav', 'theme_location'=>'header-menu' ) );
with the above code.
More Info:
child theme
Related Posts:
- Split up wp_nav_menu with custom walker
- Does Extending Multiple Nav_Menu_Walkers Allow Nested Menus?
- Call custom field into menu item
- add span class inside wp_nav_menu link anchor tag
- Determine if a navigation item has children
- Bootstrap dropdown nav pills not working with wp_nav_menu()
- Add Page ID class to nav menu items
- Bar separated navigation by extending Walker_Nav_Menu
- Bar separated navigation by extending Walker_Page
- How to Create a Custom WordPress Navigation Menu with the Code?
- Custom Nav Walker sub-menu HTML construct
- `start_el` depth argument in custom nav walker always evaluates to zero
- Benefits of using Nav Walker?
- Use walker for specific menu, or avoid use of walker
- How to display dynamic content in start_lvl function
- Add custom text to menu
- has_children in custom nav_walker
- Adding post excerpt into navigation menu
- Use wp_nav_menu to display ALL pages
- Third level navigation class
- How to add a submenu toggle button inside all “li” elements that have a submenu?
- add span class and i tag inside wp_nav_menu link anchor tag
- Change an li class name in a wordpress custom menu walker
- Add within the output of
- Is this format possible with a custom Nav Walker class?
- walker – 0 level on submenu formatting
- Determine the last child of the parent menu WP Nav Walker
- Navigation doesn’t render when wp is hosted
- getting the current sub item out of total sub items in a given dropdown (custom walker)
- How do you add a around the second level of a Menu?
- Help with walker for nav
- How Do I Add Images To Main Navigation Menu
- Walker menu not displaying at all
- Show children (sub-navigation) of active menu item only
- Adding a unique ID to each sub-menu
- Remove a class from a using Walker
- How to Add support for sub-menu item description in wordpress?
- wp_list_pages Hierarchical Help
- changing the labels inside appearance -> menus for some for the fields
- Costum walker with sub menu item count
- How do I add 3rd level of dropdowns to wp_nav_menu array?
- Help with WordPress Custom Nav Walker
- Why is my navigation in my onepage not working?
- url_to_postid method in walker_nav navigation menu causing exceptionally high TTFB
- Is it possible to get_the_post_thumbnail (Featured Image) inside a sprintf function?
- Can I now add a class in the anchor of my menu item with WordPress 5.4?
- What is inside in $item in start_el function in Walker_Nav_Menu class
- Multi-Level Nav Bar
- Adding additional html to the end of the root level in a custom nav walker
- Change markup for just 2nd list element in custom Walker menu
- Where to place a svg chevron down in my custom walker?
- Add active class to wp_nav_menu
- Output existing wp_nav_menu with a custom walker
- how to split vertical menu into two columns using walker nav menu
- How can I create this menu with wp_nav_menu()?
- Conditional Nav Menu Inside Nav Menu Across Multisite Sites
- How to add odd and even classes to all nav links through walker?
- Output sort number in wp menu list item?
- Creating custom Menu for custom theme
- Check in walker if current page is descendant
- Can’t add optional class to menu item when using Walker_Nav_Menu
- Add dynamic content block to nav section generated by custom walker
- wp_dropdown_nav function to list menu items
- Customize Walker_nav_menu to show posts if item is category
- Determine if a navigation item has children
- Walker for menus
- how to make a walker to this (in bootstrap, i try but not work)
- how can i get the page_ID in nav li [closed]
- Custom navigation / menu output (walker?)
- Nav walker bootstrap: Display 3rd level and 4th level in dropdown menu
- Custom Nav walker display current menu item children, or siblings on no children
- How to set limit only on top levels of wp_nav_menu?
- Using Image Links in WordPress Navigation Menus Instead Of Text Links
- Disguise Multi-Page site as Single Page
- Add div to specific sub-menu
- Second nav is merged with the first in mobile
- how to remove the top navigation bar or header top on wordpress website?
- Static page to one page- menu inactive items highlighted
- automatically append menu parent as first item in submenu with nav_walker
- Displaying Nav Menu
- Adding toggle-able element after menu item
- Custom register_taxonomy ins’t showing custom Nav menu
- Conditional menus based on page title
- How to test if a specific page is the front page?
- Style wp_link_pages as a select drop down list
- Mobile navigation is shown, but standard navigation does not disappear
- Add/remove image from navigation bar
- How can I order these pages in this navigation bar on this old wordpress theme?
- Add href to tag in nav menu for mobile
- Custom location for menu
- No indication of menu
- Unable to edit Navigation bar
- Should I custom code drop down menus or use a wordpress plugin?
- Navigation menu, remove item from desktop
- Jquery dropdown menus working locally, but not in WordPress [duplicate]
- Wrapping my ‘s with
- Using walker to display all menu branches at once?
- How to add a class directly on a unordered list element that is a primary navigation
- Menu drop down covers contents of page in Mobile view
- How to add toggle-able DOM element after nav menu item?