Last active
March 17, 2019 18:40
-
-
Save khoipro/0ebc940b087f9c98a0f2d29b18bca14f to your computer and use it in GitHub Desktop.
Remove menu's classes and ids.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// remove menu class and keep class to active item only | |
add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1); | |
add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1); | |
add_filter('page_css_class', 'my_css_attributes_filter', 100, 1); | |
function my_css_attributes_filter($var) { | |
return is_array($var) ? array_intersect($var, array('current-menu-item')) : ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment