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 trialjoeboo2529
9,805 PointsDifferences 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.
2 Answers
jsdevtom
16,963 PointsThank 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
4,019 PointsThank 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 !
Erika Nielsen
17,556 PointsErika Nielsen
17,556 PointsIf 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