Blacklist Menu Item Classes

/** * Clean Nav Menu Classes * */ function ea_clean_nav_menu_classes( $classes ) { if( ! is_array( $classes ) ) return $classes; $remove_classes = array( 'menu-item-type-custom', 'menu-item-type-taxonomy', 'menu-item-object-custom', 'menu-item-object-category', ); $classes = array_diff( $classes, $remove_classes ); foreach( $classes as $i => $class ) { // Remove class with menu item id $id = strtok( $class, 'menu-item-' ); if( 0 < intval( $id ) ) unset( $classes[ $i ] ); } return $classes; } add_filter( 'nav_menu_css_class', 'ea_clean_nav_menu_classes', 5 );

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk