Im trying to remove / filter our all the classes from the wp_nav_menu, EXCEPT the custom ones that i insert (in the “CSS Classes (optional)” field) when creating the menu in the admin.

I found a function that removes EVERYTHING, but thats no good

anybody got any ideas?

thanks!

2 Answers
2

One of the darker corners of the code. 🙂 Here is my take:

add_filter('nav_menu_css_class', 'discard_menu_classes', 10, 2);

function discard_menu_classes($classes, $item) {

    return (array)get_post_meta( $item->ID, '_menu_item_classes', true );
}

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *