• Hey folks. I had a need to define css classes for a specific depth of menu item, and while digging into the filter code, I found that the function start_el() in nav-menu-template.php received a $depth argument but did not pass it to the nav_menu_css_class filter.

    I wanted to be able to add a specific CSS class based on the menu item’s nesting depth, like menu-item-depth-1, menu-item-depth-2, etc. to my menu items in my theme by hooking the nav_menu_css_class filter and using the $depth argument to do so.

    Before I submit a Trac on this and potentially a patch, I’d like to solicit feedback on it- is this a useful patch/change? It’s been working quite well in my WP install and I think it could provide some benefit to people using the nav_menu_css_class filter in their themes and plugins.

    Thoughts? Thank you.

  • The topic ‘Add $depth to arguments passed to nav_menu_css_class filter?’ is closed to new replies.