I believe the current-ancestor
etc. classes are not added by the walker itself, but rather by wp_nav_menu
which is calling _wp_menu_item_classes_by_context
. Thus, your best bet is probably to add a filter to nav_menu_css_class
and remove/replace current-*
classes as needed. In its most basic form, something like:
function my_navigation_class($classes, $item){
foreach ($classes as $idx => $class) {
if ($class == 'current_ancestor') {
$classes[$idx] = 'sel';
}
}
return $classes;
}
add_filter('nav_menu_css_class' , 'my_navigation_class' , 10 , 2);
Related Posts:
- How do I add a search box to the nav menu?
- How to get IDs for objects in menu branch?
- New post notification in wp_nav_menu
- WordPress Menu Custom Walker Class
- How to use a WordPress’ existing admin icon?
- How to move parent li to end of child ul
- Show child pages by menu order using Superfish Dropdown menu?
- How to fix strange 500 Error after Editing Menu?
- Remove ‘Menus’ from Twenty Sixteen theme Customizer
- One site, 2 distinct sections: two different top nav menus?
- Can you have different menus and theme on a per-page basis?
- Adding a within ‘s from wp_nav_menu()
- Custom nav walker with different output depending on depth
- Override custom menu widget
- Placing widget to menu
- container_class doesn’t seem to be working
- Get menu item slug
- Display link with current user’s username in it in Custom Menu
- Walker_Nav_Menu: Items not nested correctly
- Add class to menu ul with active child
- jQuery cookie not working properly in wordpress
- Loop through Navbar, Output Icons
- Custom Walker anchor tag not inheriting attributes
- Check what “type” a menu item is
- next_post_link() on custom menu structure
- Custom walker with hashes instead of links (one-page layout)
- Admin only menu/page
- wp_nav_menu() showing list in a different Position?
- wp_nav_menu_items filter :: custom menus fall outside ul class
- Add within the output of
- Add CSS to head depending on nav menu walker
- WP MU: Using pages from main site in other sites’ menus
- How can I add items to the menu via the PHP file?
- WordPress warning: “private_to_published” Deprecated when creating nav with wp_update_nav_menu_item()
- two different separate sections on the same site
- Getting the current menu item id from specific menu
- how to disable default menu classes
- Adding an admin menu page showing the link twice – how to solve this?
- How to customize submenus isn wordpress theme [closed]
- 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
- Twenty seventeen Menu is not responsive not clickble
- Where is my menu editor
- wp_nav_menu not displaying the right way
- How to set classname for tag in wordpress menu?
- add 3rd party link (with script) to menu item
- WordPress Menu adds an unwanted slash before anchor
- Limit wp_nav_menu_objects() only to first-level menu items
- How to automatically redirect to first item of second navigation level in a multi-level menu?
- Hide an item from a menu to some users
- Locking in navigation labels before changing title?
- How to undo the last changes to a custom menu?
- How to Add support for sub-menu item description in wordpress?
- wp_nav_menu_items for one menu
- Add menu headings to WordPress sub menus
- Customise the custom menu widget
- I can’t add more pages to menu – menu delete pages
- Confused about the correct functioning on WordPress Menus
- add_menu_page does not render the expected result
- Admin Menu Hack (Left side in Dashboard)
- How to manipulate attributes of url-less dropdown item in a the custom wordpress menu?
- How do I remove this menu bar?
- Hide custom menu when when no menu selected
- Getting the WordPress custom menu titles and outputting them in a theme
- Second Level Menu
- Different Menus based on Category Page
- nav-menu-template and columns in sub menu
- Auto delete menu items with zero products (woocommerce)
- current-menu-item not apllying with wp_nav_menu() on ajax
- Custom link with checkbox that adds additional word to checked menu items
- menu not showing on mobile view
- Why is my navigation in my onepage not working?
- Admin menu in different languages
- Hide a menu (navigation bar) on all posts
- Edited one page in my working menu and now all menu buttons don’t open unless I right-click and open in new tab
- Parent Menu Item Requires Two Clicks for Mobile Device
- Need help with Walker_Nav_Menu class
- Is it possible to have submenu outside of menu element? I dont want submenu to be a child of menu
- Bootstrap Nav Walker Sub Menu Image
- What are some of your favorite methods for creating an accessible menu?
- Product categories are mixed when creating menu
- How to get all the menu listed in Menus Created inside the Apperance Menu?
- Add a menu item to the logged in users author page?
- Add Class to Custom Menu Widget ul
- Add parent link to its submenu
- Can’t change link for navigation item
- Loading wordpress menu in an external server
- Need direction on a seemingly complex menu walker for automatically inserting a parent link li in it’s submenu ul
- Show only second level menu items? [duplicate]
- Add item ONLY to the primairy navigation
- wp_nav_menu in 3.7 add name class nav navbar-nav
- Remove link from Page name in navigation bar
- Prevent Menu Shortcode From Formatting
- individual images as navigation design TwentyTen
- Setting up menus before making a template live
- Is it possible to add a superscript trademark symbol to a menu?
- Creating a Horizontal menu
- I want my homepage navbar to have different styling to the rest of my site, how can I do this?
- Database structure Menu Item