• Is there a way to test if a menu item in a custom menu has a sub menu? I’d like to have it show in the sidebar if and only if it has a sub menu and I haven’t been able to find any documentation on this particular thing.

Viewing 1 replies (of 1 total)
  • i was looking for the same thing, i found this simple code that works very well without spending tons of time trying to come up with your own solution:

    <?php if ( has_nav_menu( ‘primary-menu’ ) ) { ?>

    <div class=”nav-container”>
    <?php wp_nav_menu( array( ‘theme_location’ => ‘primary-menu’ ) ); ?>
    <?php get_search_form(); ?>
    </div>

    } ?>

Viewing 1 replies (of 1 total)
  • The topic ‘wp_nav_menu display in sidebar only if submenu exists’ is closed to new replies.