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!
One of the darker corners of the code. 🙂 Here is my take:
I’m trying to answer.
The function that responsible to generate classes for menu items is
_wp_menu_item_classes_by_context
in the filewp-includes/nav-menu-template.php
. You can dig there to see what classes it generate, so you can strip it out innav_menu_css_class
filter.I found that every classes that automatically generated started with
menu-item
class. So, in the filter I loop the classes array until found that class.This is my code: