I’ve made a menu in WordPress backend with 3 levels depth.
(four main tabs with two sub level items)
I would like to know how I can get the number of tabs created automatically and add this number to a class on the ul
(i.e: .item-4
)
Any ideas? I’m already using a custom walker.
You can use the
wp_get_nav_menu_object
to retrieve the menu as an object, which you can subsequently establish the length of. Like this:You can the use this on your call to
wp_nav_menu
: