Whitelist Menu Item Classes

/** * Clean Nav Menu Classes * */ function ea_clean_nav_menu_classes( $classes ) { if( ! is_array( $classes ) ) return $classes; $allowed_classes = array( 'home', 'menu-item', 'current-menu-item', 'current-menu-ancestor', 'menu-item-has-children', ); return array_intersect( $classes, $allowed_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