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

James Home
James Home
12,011 Points

WordPress wp_nav_menu - adding menu_id

I am using the start theme underscore.

I am trying to add an menu id to the wp_nav_menu in header.php, however I can add a class but not an id which when I attempt to using menu_id => menu.

    <nav id="site-navigation" class="main-navigation" role="navigation">
        <a href="#menu" class="icon-toggle toggle" aria-controls="menu" aria-expanded="false"><b class="srt"><?php _e( 'Primary Menu', '_sp' ); ?></b></a>
        <?php wp_nav_menu( array('theme_location' => 'primary', 'menu_id' => 'menu', 'menu_class' => 'nav' ) ); ?>
    </nav><!-- #site-navigation -->

I was thinking that I would need to override the current settings in the function.php file.

2 Answers

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Do you have a menu created on the backend to display? What is the source code outputting when you use the code you're using?

James Home
James Home
12,011 Points

Hi Zac,

Thanks for responding.

I figured it out after you asked about the backend. I had to create a new menu in the admin panel. Would have been nice if I could still use the same theme location.