How to make Roots_Nav_Walker to have 3 or more depths?

I tried changing the code in nav.php to:

 if (current_theme_supports('bootstrap-top-navbar') && !$args['depth']) {
    $roots_nav_menu_args['depth'] = 4;

// tried 0 as well as suggested in codex but to no avail :( 

and for but I still can’t get the depth to more than the second level. I think I have three level like this:

<img src=">

but I end up still having 2 level regardless:

Any help?

You’ll have to modify the walker; it doesn’t support 3 levels because neither does Bootstrap.

Thanks for the answer @Foxaii!

Any guide/suggestion which files I should start looking to modify the walker? Thanks in advance!

You’ll want to check out the history of lib/nav.php on GitHub. We supported 3 levels when Bootstrap 2 did (I think the class was .dropdown-submenu) so most of the code needed already exists.

You’ll also want to search for Bootstrap 3 submenus to find the appropriate CSS.


If you look in nav.php - which is where you should be like @Foxaii said, you will see on lines 83-85 you can change the depth there… not sure how far that will get you…

  if (current_theme_supports('bootstrap-top-navbar') && !$args['depth']) {
    $roots_nav_menu_args['depth'] = 2;
1 Like

Thanks so much for the heads up @Foxaii

@JulienMelissas thanks man appreciate the help. Tried that but seems like bootstrap 3 doesn’t support more than 2 depth so nothing happened.

Most probably will follow as @foxaii suggested and share my solution here.

Cheers guys!

The markup is probably there for the other dropdowns, just hidden. I recently did a nav menu with sub menus (they don’t create an extra dropdown) so I know it works.

This is the old nav.php file from about 8 months ago, before bootstrap 3, when bootstrap 2 supported the sub-sub menus:

This example on Bootply might help you:

All this said, be careful about your subnavs. They were removed from Bootstrap 3 for a reason - they’re less intuitive, and sometimes difficult to use.

Good luck!