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

Ian Mackenzie
Ian Mackenzie
11,062 Points

After entering code my backend does not show at all!

<?php
add_theme_support('menus');

function register_theme_menus(){

    register_nav_menus(
        array(
            'primary-menu' => _('Primary Menu')
            )
        );
}
add_action('init', 'register_theme_menus');
?>

2 Answers

For register_nav_menus:

"This function automatically registers custom menu support for the theme therefore you do not need to call add_theme_support( 'menus' );"

So, in other words, you don't have to use the add_theme_support('menus') you have. You should be able to use

<?php
function register_theme_menus() {
  register_nav_menus(
    array(
      'primary-menu' => __( 'Primary Menu' )
    )
  );
}
add_action( 'init', 'register_theme_menus' );
?>

I believe your error may be related to the fact that you were only using a single underscore in front of the text you wanted localized, you need to use two underscores __

Give that a try and we can troubleshoot it from there if necessary.

Ian Mackenzie
Ian Mackenzie
11,062 Points

Thanks Mike for your quick response and you nailed it. I was one underscore short.

Glad it helped, Ian!

Jill Ferron
Jill Ferron
5,023 Points

Super helpful thanks