You are viewing this site in a simplified layout because your browser does not yet support CSS Subgrid.

op111.net

Search op111.net

How to remove the ID and all CSS classes from WordPress menu items

The three lines below will remove all IDs and classes from menu items, including classes for the current item:

add_filter('nav_menu_css_class', '__return_empty_array');
add_filter('nav_menu_item_id', '__return_empty_string');
add_filter('page_css_class', '__return_empty_array');

The current item can still be targeted using the aria-current attribute:

.menu li a[aria-current="page"] {
  color: red;
}

Documentation