Skip to content

Instantly share code, notes, and snippets.

@khoipro
Last active March 17, 2019 18:40
Show Gist options
  • Save khoipro/0ebc940b087f9c98a0f2d29b18bca14f to your computer and use it in GitHub Desktop.
Save khoipro/0ebc940b087f9c98a0f2d29b18bca14f to your computer and use it in GitHub Desktop.
Remove menu's classes and ids.
// 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