Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress WordPress Theme Development Building Out WordPress Navigation Coding A Basic Navigation in WordPress

Matt Jakachira
seal-mask
.a{fill-rule:evenodd;}techdegree
Matt Jakachira
Front End Web Development Techdegree Student 5,536 Points

Adding a second menu to a sidebar

I added a second menu in my functions file like this

'markets-nav' => __('Markets Menu')

and the added the following code to the sidebar where I want the menu to be

<?php $args = array( 'menu' => 'markets-nav', 'menu_class' => 'sidebar-nav', 'container' => 'false' );

            wp_nav_menu( $args );

          ?>

But when I go to add the menu in the backend it also takes over my header menu. What am I missing in this process?

3 Answers

Did you register the navigation in your functions file? read here

Matt Jakachira
seal-mask
.a{fill-rule:evenodd;}techdegree
Matt Jakachira
Front End Web Development Techdegree Student 5,536 Points

Here is my code for registration

add_theme_support( 'menus' );

function register_theme_menus() {

register_nav_menus(
    array(

        'header-menu'  => __('Header Menu'),
        'markets-nav'  => __('Markets Menu')

        )

 );

}

add_action('init', 'register_theme_menus');

Matt Jakachira
seal-mask
.a{fill-rule:evenodd;}techdegree
Matt Jakachira
Front End Web Development Techdegree Student 5,536 Points

and then here is the main menu placement

<?php $args = array( 'menu' => 'header-menu', 'menu_class' => 'nav navbar-nav flex-nav', 'container' => 'false' );

            wp_nav_menu( $args );

          ?>