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 trialMatt Jakachira
Front End Web Development Techdegree Student 5,536 PointsAdding 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
David Tonge
Courses Plus Student 45,640 PointsDid you register the navigation in your functions file? read here
Matt Jakachira
Front End Web Development Techdegree Student 5,536 PointsHere 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
Front End Web Development Techdegree Student 5,536 Pointsand 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 );
?>