WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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 Sep 3 '14 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. – Matthew Bakaitis Sep 3 '14 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 Sep 3 '14 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... :( – Matthew Bakaitis Sep 3 '14 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. – Melissa Post Dec 9 '14 at 14:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.