You can use Walker_Nav_Menu
(WordPress Default class).
Here is an example –
In header.php
file –
<nav id="header-menu">
<?php
wp_nav_menu( array(
'theme_location' => 'primary',
'walker' => new Child_Wrap()
) );
?>
</nav>
In my functions.php
file –
class Child_Wrap extends Walker_Nav_Menu
{
function start_lvl(&$output, $depth = 0, $args = array())
{
$indent = str_repeat("\t", $depth);
$output .= "\n<div class="sub-menu-holder">$indent<ul class=\"drop-down\">\n";
}
function end_lvl(&$output, $depth = 0, $args = array())
{
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul></div>\n";
}
}
Above is an example of my code you can change as per your requirement.
Thanks.
Related Posts:
- Any docs for wp_nav_menu’s “items_wrap” argument?
- Does Extending Multiple Nav_Menu_Walkers Allow Nested Menus?
- Bootstrap dropdown nav pills not working with wp_nav_menu()
- Show child pages by menu order using Superfish Dropdown menu?
- Bootstrap drop down menu with wp_nav_menu
- How to Create a Custom WordPress Navigation Menu with the Code?
- WordPress 3.5 dropdown menu
- Menu item with no page, but with dropdown
- Add css class to dropdown
- Using a shortcode to create a dropdown menu from wp_nav_menu list items
- Menu in left side don’t appears with dropdown
- getting the current sub item out of total sub items in a given dropdown (custom walker)
- How to add html attributes to the “ul” html tag with “wp_nav_menu” function?
- How to remove dropdown from wp_nav_menu
- styling wp_nav_menu – horizontal, sub-menu drop downs
- Replace the slug of parent pages with # [closed]
- wp_get_archives doesn’t take effect from css or html
- Adding archive years to my menu
- Nav menu classes ‘has-dropdown’ but no ‘active’
- Drop Down menu expanded by default (on front page) [closed]
- Custom menu – different submenu for first menu item
- dropdown menu, with walker
- Dropdown primary navigation menu not working
- Is there any way to change the CSS class applied to 2nd level sub menu ul’s?
- WordPress menu issue – if there are child links partents won’t click
- How can I create this menu with wp_nav_menu()?
- Responsive Dropdown Menu
- Foundation Scripts not loading (custom theme)
- Reveal hidden submenus on page load – Twenty Fifteen theme
- No indication of menu
- wp_dropdown_nav function to list menu items
- How to make a drop down menu with categories
- How to add an tag when a menu item is a dropdown(or has a sub-menu) [duplicate]
- How to add posts with thumbnails to my dropdown menu?
- Should I custom code drop down menus or use a wordpress plugin?
- Keeping my Sub Menu open when hovering on its list items
- Jquery dropdown menus working locally, but not in WordPress [duplicate]
- Add a page to a subscribers account
- What is the best way to incorporate responsive dropdown navigation menu into custom theme?
- Menu items do not “open” when mouse hover over them?
- Icon not shown in Dropdown menus in Twenty Seventeen Theme
- Unregister Nav Menu from Child-Theme
- New post notification in wp_nav_menu
- Deleted pages are NOT removed from custom menus?
- How to use a WordPress’ existing admin icon?
- Keeping parent menu items active in child pages
- Add Page ID class to nav menu items
- Way to bulk delete menu items in new 3.x Appearance > Menus system?
- Pass a parameter to a menu walker
- One site, 2 distinct sections: two different top nav menus?
- Can you have different menus and theme on a per-page basis?
- Move admin menu at the end
- Should the caching of WordPress menus be specific to each page?
- Not able to get current menu ID
- How to make pages metabox display all hierarchy in menu admin?
- Bar separated navigation by extending Walker_Page
- Get parent page/menu id of current post
- Edit Custom Links Menu markup: Making a Social Media Menu with linkable icons
- Customizing a walker menu class
- wp_nav_menu (secondary menu) not adding current classes
- How to add parent element’s title to nav menu’s child?
- How can I detect whether a BuddyPress page is active from within my theme?
- WP /wp-admin/admin-ajax.php produces 404
- Add custom text to menu
- How to make a custom menu based on a category or tag?
- How can I add divs or change li in the submenu of the menu_nav
- Get top items number from wordpress menu
- Operable default menu *and* custom 3 menu
- Prev / Next menu item
- WordPress menu permalink redirects to wrong page
- HTML to WordPress Menu convert
- add span class and i tag inside wp_nav_menu link anchor tag
- Hide sub menus sometimes
- How to change menu URLs to hashes?
- Grey out nav buttons unless is_user_logged_in()
- How to approach this menu design?
- Trying to Create Menu in WordPress
- ‘Users’ and ‘Appearance’ have disappeared from dashboard menu [closed]
- Making nav menu sticky and transparent
- Jupiter theme Mega menu option not available
- Sub Menu does not display using Nav Walker
- How to handle many different menus?
- Get Menu Name inside walker
- How to add ul and li classes to nav in wordpress
- Where to implement custom walker class?
- Responsive menu gone on wordpress Responsive theme
- wp_page_menu not working right?
- How can I add text to a single nav menu item?
- Alternative to wp_get_nav_menu_items?
- Adding menu items?
- Adding existing links to custom navigation menus?
- How to add attribute in menu code
- How to truncate menu label in wordpress?
- In the Admin Dashboard, can I choose which sections to display?
- How to change the color of a menu item [closed]
- Walker menu not displaying at all
- wp_nav_menu not displaying the right way
- magic “MENU” button under Twenty Twelve theme
- Remove first separator in wp_nav_menu
- wp_nav_menu check both hierarchy fail?