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 Coding A Basic Navigation in WordPress

Jake Ford
Jake Ford
9,230 Points

Why do we have to create the function register_theme_menus()?

If register_nav_menus() is what actually adds our menu to wordpress, then why are we wrapping it in another register_theme_menus() function?

I don't see the point of it?

1 Answer

Fulvio Giacomello
Fulvio Giacomello
5,095 Points

I think we (technically) don't have to. We could hook the 'register_nav_menus' function to 'init' like this:

add_action( 'init', register_nav_menus ( array( 'primary_menu' => __( 'Primary Menu' ) ) ) );

but this code it's harder to read and understand