I was able to work this out by using a hook that I grabbed from Artemiy Egorov’s answer on this post https://stackoverflow.com/questions/5034826/wp-nav-menu-change-sub-menu-class-name so I figured I’d share in case someone else needs it too:
add_filter( 'nav_menu_submenu_css_class', 'rename_sub_menus', 10, 3 );
function rename_sub_menus( $classes, $args, $depth ){
foreach ( $classes as $key => $class ) {
if ( $class == 'sub-menu' && $depth == 0) {
$classes[ $key ] = 'first-level-sub-menu';
} else if ( $class == 'sub-menu' && $depth == 1) {
$classes[ $key ] = 'second-level-sub-menu';
} else if ( $class == 'sub-menu' && $depth == 2) {
$classes[ $key ] = 'third-level-sub-menu';
}
}
return $classes;
}
Related Posts:
- Multi Level Bootstrap Navigation Menu in WordPress
- Show only 2nd level of navigation depending on active navigation
- Custom Nav Walker sub-menu HTML construct
- Adding different classes to anchor in navigation menu
- how to automatically generate hierarchical menus from hierarchy of pages?
- How to display dynamic content in start_lvl function
- Menus like a CMS
- How to have custom menu Item CSS Classes for wp_page_menu() or wp_list_pages()
- How to add a submenu toggle button inside all “li” elements that have a submenu?
- Check if menu id = $specific_id – then insert specific
- wp_nav_menu() with multiple Class
- Trying to Create Menu in WordPress
- How do I add recent posts to the menu?
- Automatically list top level menu item child pages
- Check if menu_item has children or has parent
- Add a submenu to wp_nav_menu
- How to buid wordpress menu with auto width sub-menu items in dropdown menu without any items sharing one line [closed]
- Adding toggle-able element after menu item
- How to Add support for sub-menu item description in wordpress?
- Add Different Class on Different Ul in twenty-twentyone theme
- wp_nav_menu container style args
- Bootstrap Theme Migrated to WordPress
- WordPress + Bootstrap: Replace primary navigation menu on mobile?
- How can I click the parent menu then redirect to a special URL?
- Creating navigation out of specific IDs and their children?
- Where to place a svg chevron down in my custom walker?
- Add href to tag in nav menu for mobile
- Conditional Nav Menu Inside Nav Menu Across Multisite Sites
- Show Child of Parent Page including all other parents
- nav_menu: how to force a subpage switching on the parent menu
- How was this menu system created?
- Display sub menus as separate lists
- Programmatically add a Navigation menu and menu items
- Show current navigation path from menu
- Call custom field into menu item
- Exclude Private, Draft pages from Primary Nav when using custom menu
- wp_nav_menu always falls back to a menu
- wp_get_nav_menu_items how to exclude sub level menu items?
- Add class to top level menu item if it has multiple child levels
- Add custom attributes to menu items without plugin
- Simple Navigation Walker – Wrapper-class around first sub-menu
- Exclude one item from wp_list_pages( $args );
- How to drag multiple menu items at once in WordPress?
- Customizing the a tag with Semantic UI
- Put a wp_nav_menu inside another one
- Not able to get current menu ID
- Add class to active top level (grandparent) menu item
- Check if wp_nav_menu items have submenus
- how to only add a top-level admin menu without it creating a sub-level-menu
- Why is ‘nav_menu_item_args’ filter’s $item argument empty?
- WordPress wp_nav_menu with a nav tag
- `start_el` depth argument in custom nav walker always evaluates to zero
- Use walker for specific menu, or avoid use of walker
- Change where navigation bar links?
- Programmatically set current-menu-item using wp_nav_menu
- Adding Custom “Current Menu Item” class to navigation?
- No “current-menu-ancestor” class added when browsing an archive page
- Change an li class name in a wordpress custom menu walker
- Separator for custom nav menu
- add_submenu_page function to show videos table
- current-menu-item class is not added
- wp_page_menu not working right?
- Using _s theme, menu changes do not affect header menu
- How to get rid of the home link in nav menu?
- Is it possible to add a dynamic link in the main navigation in a child theme
- display menu as table layout
- Insert a div class inside wordpress menu
- Show children (sub-navigation) of active menu item only
- Menu Arrow for Child Element
- How to make wordpress nav menu use post custom meta data
- retrieves menu and converts it to a readable array
- add another html tag after li element in wp_nav_menu
- Get parents child pages
- Odd spacing in Navigation Bar [closed]
- wp_list_pages Hierarchical Help
- How to avoid the and which added when custon menu widget is used
- How to add a menu that belongs to parent blog to all child-blogs?
- An alternative to WordPress’s built-in menu functionality
- Dropdown primary navigation menu not working
- Is there any way to change the CSS class applied to 2nd level sub menu ul’s?
- Link after WordPress
- Problem with links once in portfolio item
- Is it all right to put the whole tag into template_part file?
- Misleading behaviour on Menu & Theme location
- Generate Submenu based on Parent Page using If Statement
- Building a menu from a large number of pages?
- Show thumbnail to category items in wp_nav_menu(), how?
- How to select particular menu position in wordpress?
- Links in new menu don’t work
- Add dynamic content block to nav section generated by custom walker
- Next/previous a-like single navigation
- How to output the menue structured for tabbed navigation?
- How to create a menu super voice in WP?
- Walker for menus
- WordPress Navigation
- Change sub-menu css class
- How to display a submenu as a popup when clicking a button?
- how can i get the page_ID in nav li [closed]
- How do i add logo in wordpress studiopress (glam theme)?
- Add featured posts to nav menu