I'm working on a new theme to replace an old one. The existing theme has custom menus and I can't figure out why in my new theme a call to has_nav_menu is always coming back false.

In my functions.php, I register the menus:

    function register_menus() {

                'global-nav' => 'Global Navigation',
                'footer-nav' =>  'Footer Links',
                'sitemap' =>  'Site Map',
                'share-ideas' => 'Share Ideas'

    add_action( 'init', 'register_menus' );

Then in a test page, I have the following:

<div class="container">
    if ( has_nav_menu( 'global-nav' ) )
        echo '<h1>menu found</h1>';

    } else {
        echo '<h1>menu not found, menus registered are:</h1>';
        $menus = get_registered_nav_menus();

        foreach ( $menus as $location => $description ) {

            echo $location . ': ' . $description . '<br />';


The weird thing: while has_nav_menu always returns false, the get_registered_nav_menus loop shows the locations exist.

Also, in the admin->menus screen, the menus all show up fine.

So clearly I'm missing something as get_registered_nav_menus says I have registered them properly but has_nav_menu fails. Unfortunately, I can't figure out what step I might have skipped.

  • At the risk of asking a stupid question: I know you've created the menus, but have you assigned them to menu locations? That's what has_nav_menu is actually testing.
    – sabreuse
    Commented Sep 3, 2014 at 14:05
  • There are no stupid questions. But has_nav_menu on the codex says is checks 'Whether a registered nav menu location has a menu assigned(true) or not(false).' Isn't that what register_nav_menus is doing? Assigning a location (the key in the array) to a menu (the value)? In other themes, I've used a similar construction...which is why I'm confused. Commented Sep 3, 2014 at 16:48
  • register_nav_menus creates your empty menu locations, but it doesn't assign any particular menus to them. You have to do that as a separate step on the Admin->Menus screen, either in the Manage Locations tab or at the bottom of each individual menu's screen.
    – sabreuse
    Commented Sep 3, 2014 at 17:33
  • Yep, and those show the menus all have assignments. I appreciate the feedback and the double-checking. I'm sure I'm missing something trivial like this...but still unsure what... :( Commented Sep 3, 2014 at 18:50
  • It might be a new bug - I'm having the same issue with a site that was working fine in 3.9.1, but the menus stopped displaying in 4.0.1. About get_registered_nav_menus returning something different — it looks like has_nav_menus checks for the menu location in _wp_registered_nav_menus first (see more on core.trac). Anyway... @MatthewBakaitis did you find a fix? I'm just commenting out has_nav_menus for now. Commented Dec 9, 2014 at 14:47


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.