Support » Themes and Templates » Wrong menu being displayed by wp_nav_menu()
3 years, 3 months ago
Firstly I hope this is posted in the right forum!
I’m creating my own theme and I’ve added menu support, but I’m having trouble with the wrong menu being displayed.
In functions.php I have
add_action( 'init', 'roganty2_menus' );
'main-menu' => 'Main Menu'
In header.php I have
<?php wp_nav_menu( array('theme-location' => 'main-menu', 'container' => false, 'depth' => 1) ); ?>
In the back end I have two menus, ‘Long Menu’ and ‘Short Menu’
I have selected ‘Short Menu’ to be in the ‘Main Menu’ location, but it only displays ‘Long Menu’.
The only way it displays ‘Short Menu’ is if I delete ‘Long Menu’. As soon as I recreate ‘Long Menu’ it starts displaying ‘Long Menu’ again!
Other things I have tried:
Has anyone got any ideas??
Ok, I’ve been testing this for a while now.
All my other themes, when I select a menu, that menu is displayed!
It’s only with this one theme!!!!
I’ve deleted all menus, and recreated them using different names, and still, only the first menu I created is the one used!! What the hell is going on!?
I have checked my code against the other themes, and its the same!
I’ve tried renaming the menu location.
I’ve tried adding a second menu location.
But still only the first menu is used!
I can’t believe I’ve been so stupid!!
It should be ‘theme_location’ with underscore!