I'm running into a really weird problem.

Some quick background: I cloned this workflow from one I've been using before but just updated everything including node packages and the gulp functions and workflow. This worked perfectly fine before and now it's suddenly giving errors and not working as expected.

So I'm trying to create custom menus and have them registered like I normally do:

            'primary' => 'Primary Menu',
            'secondary' => 'Footer Menu',
            'tertiary' => 'Legal Menu'

I noticed it doesn't display at all but still shows up in the admin dashboard to add/remove items. So I did some testing and this is what I got:

                        $menus = get_registered_nav_menus();
                        foreach ( $menus as $location => $description ) {
                            echo $location . ': ' . $description . '<br />';

                        echo has_nav_menu('primary')?'true<br />':'false<br />';
                        $registered_nav_menus = get_registered_nav_menus();
                        echo isset( $registered_nav_menus[ 'primary' ])?'true<br />':'false<br />';
                        $locations    = get_nav_menu_locations();
                        var_dump($locations) ;

                        $locations = get_theme_mod( 'nav_menu_locations' );

                        wp_nav_menu( array( 
                            'menu' => 'primary', 
                            'theme_location' => 'primary',

And this code give me this output:

primary: Primary Menu
secondary: Footer Menu
tertiary: Legal Menu


array(0) { } 
Array ( )

// These are not the correct menu items, it should only be showing the first 3. This is showing all pages on the website
Privacy Policy

Basically, some functions show that it is registered and show the registered menus, while others show it isn't. I normally don't ask questions here because it's usually an error on my end so I eventually manage to find the problem, but in this case I can't think of any other reason this could happen unless there's a bug in the latest WordPress version.

If anyone could provide some insight on this that'd be amazing as I'm completely stumped!

WordPress version: 5.9 PHP version: 7.4.27

1 Answer 1


Do you check the menu already set to the location?

Menu Image

  • 1
    This is what happens when you take a break... Thank you. I spent way too much time trying to fix this and it was right there
    – Jan
    Feb 16, 2022 at 3:17

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.