当然,您可以过滤掉所有的类,但不包括您想要的类。
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 )
);
}