I'm creating a menu that will have sub-menu > sub-menu > sub-menu. The styling is really involved so ideally I could rename the class name "sub-menu" based off what level of sub-menu it is or at least add a class (ie 1st sub-menu add .top-sub-menu, 2nd sub-menu add .second-level-sub-menu, 3rd sub-menu add .third-level-sub-menu).
- Is there any way to do this in WP core?
- If not, are what would be the best way to achieve this result?
I attached the html of what I've got going on if that helps. Any help is much appreciated. Thanks!
$depth
of the menu items which is exactly what you're asking about, anybody with basic beginner level PHP skills can use anif
statement to check its value and return a different class. The answer by vralle even uses the depth to add a class with the depth value and does it in a filter that can be added to any menu. Note that any answer you got here would not be a copy paste solution