WordPress.org

Ready to get started?Download WordPress

Forums

wp_nav_menu 'depth' argument won't work (2 posts)

  1. notpoppy
    Member
    Posted 2 years ago #

    I am designing a new theme at the moment and am trying to use wp_nav_menu to create a menu of pages that is two levels deep. Here's my code:

    <?php wp_nav_menu( array( 'container' => false, 'menu_id' => 'nav', 'theme_location' => 'primary', 'fallback_cb' => 'bp_dtheme_main_nav', 'depth' => 2 ) ); ?>

    I added 'depth' => 2 as per the instructions in the codex but it has no effect - it continues to allow to to navigate beyond the second level in my menu,

    Can anyone see what is wrong here?

  2. notpoppy
    Member
    Posted 2 years ago #

    Ah - figured it out. This is because 'fallback_cb' => 'bp_dtheme_main_nav' (added by Buddypress) sets the depth at 0 in the theme's functions.php. I re-defined it in my theme's functions.php and now it works as desired.

    Resolved.

Topic Closed

This topic has been closed to new replies.

About this Topic