Created
December 29, 2016 08:47
-
-
Save certainlyakey/44379b32b8e75c7cd3b3f50027b4155a to your computer and use it in GitHub Desktop.
Remove all classes in a Wordpress-based menus, except those given
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 all classes in a Wordpress-based menus, except those given | |
function css_attributes_filter($var) { | |
return is_array($var) ? array_intersect($var, array('current-menu-item','current_page_item','current-page-ancestor','current-menu-ancestor','current-menu-parent')) : ''; | |
} | |
add_filter('nav_menu_css_class', 'css_attributes_filter', 100, 1); | |
add_filter('nav_menu_item_id', 'css_attributes_filter', 100, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment