"Python Basics (2015)" was retired on June 22, 2018. You are now viewing the recommended replacement.

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 The wp_nav_menu Function

Differences between register_nav_menu( 'primary-menu', 'Primary Menu' ); and 'primary-menu' => __( 'Primary Menu', 'h)?

whats a different between these two? I cant wrap my head around it just yet.

If you are looking at the codex and wondering why there is

<?php register_nav_menu( $location, $description ); ?>

and

<?php register_nav_menus( array( $location => $description ) ); ?>

The difference between the two is whether you want to have more than one menu. They are different functions that handle their arguments differently. The first function takes two arguments that are equivalent to the key value pair for the first menu element in the array and is only going to work for one menu. The second function can accept multiple menus as key value pairs.

I came across this question while trying to figure out what the double underscores mean before __( 'Primary Menu'). It turns out that it has to do with translating text. If you are interested, here is what WordPress has to say about it

2 Answers

jsdevtom
jsdevtom
16,963 Points

Thank you Erika Nielsen! I don't think I would have found the information about

 __( 'Primary Menu')

without this comment. Also, Had you posted your answer in the answer section instead of the comments, I could have given you a +1 :-)

Advait Junnarkar
Advait Junnarkar
4,019 Points

Thank you so much for your answer Erika Nielsen !!! I was starting to pull my hairs out Googling __() to no avail. I would never have thought it has something to do with internationalisation / translation of text. Great to know !