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

Different Ways of Registering Menus

Hi,

I was recently following the Themeshaper's 'How to Create a Wordpress Theme' (http://themeshaper.com/2012/10/22/the-themeshaper-wordpress-theme-tutorial-2nd-edition/), and noticed they had a different way of registering their menu.

In the functions.php they use:

register_nav_menus( array(

'primary' => __( 'Primary Menu', 'shape' ),

then in the header.php they use:

<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>

While in the treehouse tutorials, in functions.php is:

add_theme_support( 'menus');

and in the header:

$args = array(
        'menu' => 'main-menu',
    );

wp_nav_menu( $args );

I was just wondering what the difference between using these methods is, and if there are any specific advantages or disadvantages to each?

Thanks for your help!

1 Answer

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

The first code allows you to create multiple menu locations. We just used a more simplified way in our videos :)

Sorry for the late response! I usually only see posts with the tag 'WordPress'