No matter what parameters I pass to wp_nav_menu it always comes out blank (NULL).
Here’s how I registered the nav support in functions.php:
function mytheme_addmenus() {
add_theme_support( 'nav-menus' );
if ( function_exists( 'register_nav_menus' ) ) {
register_nav_menus(
array(
'rightsidebar' => 'Right Sidebar Menu'
)
);
}
}
add_action( 'init', 'mytheme_addmenus' );
Then I create a new menu in the admin and assign it to the “Right Sidebar Menu” location. The ID of the menu is 5, the name is test.
None of the following return anything (NULL to be precise). I’m calling it in sidebar.php:
wp_nav_menu('menu=test');
or
wp_nav_menu(array('menu' => 'test'));
or
wp_nav_menu($a = array('menu' => 'test'));
or
wp_nav_menu('menu_id=5');
or
wp_nav_menu('menu=5');
or
wp_nav_menu('menu=rightsidebar');
However, when I call the following I get a valid object containing the menu meta data:
wp_get_nav_menu_object('test')
So clearly ‘test’ is a valid menu= parameter.
Am I missing something? Please help!
PS. WordPress version 3.3. Theme is super basic built from scratch.
you are calling the menu by menu id (which you are saying is 5) but you are registering it by a theme location.
Try
wp_nav_menu( array( ‘theme_location’ => ‘rightsidebar’ ));
wp_nav_menu echoes the reult instead of returning it. If you want to return the menu string, try using :