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

Emil Wallgren
Emil Wallgren
11,737 Points

Wordpress menus messing with me

Hi!

I've got this problem. Created a header-menu and a footer-menu. Added register_nav_menu for both of my menus in functions.php.

But somehow, the header-menu always become the footer-menu. For example: If header-menu contains 1 2 3 and footer menu contains 4 5 6. Then the output of header-menu becomes 4 5 6 and the footer menu also becomes 4 5 6. What's wrong?!! Been debugging for an hour....

Here's the functions.php section:

<?php
function register_my_menus() {
    register_nav_menu('header', __( 'Header-Meny' ));
    register_nav_menu('footer', __( 'Footer-Meny' ));
}
add_action( 'init', 'register_my_menus' );
?>

Here's the header.php section:

<ul class="nav navbar-nav">

                        <?php 
                                $args = array(
                                    'theme-location' => 'header',
                                    'container'             => false,
                                    'items_wrap'      => '<li>%3$s</li>',
                                );
                                    wp_nav_menu( $args );
                         ?>                         

1 Answer

Emil Wallgren
Emil Wallgren
11,737 Points

Fixed it. Theme-location should be theme_location :-)

Gary Calhoun
Gary Calhoun
10,317 Points

Sorry just seeing this, glad you were able to fix it!