i got a answer from another thread.. which is bellow
add_filter('nav_menu_css_class', 'discard_menu_classes', 10, 2);
function discard_menu_classes($classes, $item) {
$classes = array_filter(
$classes,
create_function( '$class',
'return in_array( $class,
array( "current-menu-item", "current-menu-parent" ) );' )
);
return array_merge(
$classes,
(array)get_post_meta( $item->ID, '_menu_item_classes', true )
);
}
ref : http://wordpress.stackexchange.com/questions/30417/removing-all-classes-from-nav-menu-except-current-menu-item-and-current-menu-par
Related Posts:
- Dynamically exclude menu items from wp_nav_menu
- Add custom menu item using wp_nav_menu_items filter
- Custom search filter causes menu and query_posts problems
- Unregister Nav Menu from Child-Theme
- Allow html tags in WordPress Custom Menus Description Field
- Using filters to change href of nav menu page link
- How to apply a class to the second word in menu list item?
- WordPress nav_menu_link_attributes Not Working
- Is it possible to add a filter for the output of nav-menu items in admin?
- if role is logged in then do something
- Filter menu item to add classes/attributes?
- Edit html for menu items in default frontend menu
- Set Item Order with wp_nav_menu_{$menu->slug}_items
- When at / ( or “home”) my menu doesn’t get a current-menu-item class
- How to add parent element’s title to nav menu’s child?
- Why is ‘nav_menu_item_args’ filter’s $item argument empty?
- Add class to active element and its parent in nav menu
- display only the wp_nav_menu, which has the current-menu-item
- Removing strip_tags not working on nav_menu_description
- Third level navigation class
- How to add #navbar to all page links?
- add span to top level links of a wordpress menu called “main”
- Debugging – trying to add search box to menus
- wp_list_pages() but only show children on the branch you are on
- From a page, is it possible to find entry’s “menu_item_parent”?
- Add active class to top-level menu items when viewing single for that post type
- add_filter on menu items to add a menu item
- Insert other menus as submenus of a main menu
- list category posts under its item in menu
- Prevent menu from loading in a page template [duplicate]
- Insert a div before the wp_nav_menu
- How to change menu structure?
- Secondary Navigation Menudisappeared When using wp_nav_menu_items
- remove specific classes from menu items
- wp_nav_menu action/filter help
- add_filter for where statment issue
- Add a counter beside menu item label
- Add custom link on the fly to nav menu
- menu-item class missing on wordpress menu
- Filter to hook into menu items and add a custom attribute
- if role is logged in then do something
- Possible to append class to nav menu added to widget area?
- Modifying Woocommerce menu based on tags and categories
- Why does WordPress convert absolute URLs to relative URLs for menu items?
- Menu location switcher – example code fails
- Add Featured Image and Title to wp_nav_menu items
- Show thumbnail to category items in wp_nav_menu(), how?
- Add Class to Custom Menu Widget ul
- Avoid changing menu query with suppress_filters => false
- Removing menu item doesn’t get removed on edit post
- Add Protocol to Custom Menus
- How to modify menu text in callback function of ‘walker_nav_menu_start_el’ hook
- Why is WordPress stripping anchor links from mneu item URLs?
- Add button and title on submenu WordPress
- In WordPress, I want to use code to filter out one menu item (page) from displaying when I call wp_nav_menu() function
- Add a custom walker to a menu created in a widget
- Does WP REST API have a built in route for calling menu?
- wp_nav_menu remove class and id from li
- How can I add (custom) modules to Appearance -> Menus?
- How can I remove a menu item programmatically?
- When add wordpress page in menu it converted in to custom link
- How can I add a sub menu to an existing navigation menu in WordPress?
- Adding different classes to anchor in navigation menu
- Main menu – get rid of titles?
- Arrow down in menu not displaying
- How to gain access to each menu item in wordpress?
- Second nav is merged with the first in mobile
- Import menu tree to custom menu from csv or xml, many nested menu points
- Create Dropdown menu Using wp_nav_menu() function
- Update Nav Menu Items Programmatically
- Programmatically create and place a nav menu in a theme location?
- Add Button to Bottom of Mobile Menu
- how to remove the top navigation bar or header top on wordpress website?
- Show Home Link In wp_nav_menu but only on primary menu
- How to use buttons elements for tgetWordPress menu items?
- automatically append menu parent as first item in submenu with nav_walker
- How do you add a around the second level of a Menu?
- Move Sticky Nav Menu Below WordPress Tool bar when tool bar enabled
- How to use wp_nav_menu with hashtag links?
- Strange menu behaviour wordpress admin [duplicate]
- Lost admin “manage_link” capability WordPress. No “Links” menu item in admin menu
- How to add active class to separate page link?
- 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
- How to change navwalker’s dropdown mark-up?
- Bootstrap navbar responsiveness on WordPress theme menu not working
- Show navigation header menu by post and categery
- How to add buddypress sub-menu items to other menus
- Custom location for menu
- No indication of menu
- Set menu item class into body
- Creating a custom menu
- List WordPress Custom Menu’s active parent level’s children as separate menu
- What is the best way to incorporate responsive dropdown navigation menu into custom theme?
- Icon not shown in Dropdown menus in Twenty Seventeen Theme
- How to change WP menu item type?
- How to get the navigation menu items? [closed]
- conditional menu with custom fields
- Confused over difference between post and menu hierarchy