How to create a menu from get_nav_menu_locations when it always returns an empty array?

admin

Administrator
Staff member
In the wordpress dashboard I've created a menu under appearance -> menus and named it "my-menu".

Using example code from <a href="http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items" rel="nofollow">this page</a> I'm trying to build the menu. In my
Code:
/wp-content/themes/blankslate/header.php
I add the following code:

Code:
$menu_name = 'my-menu';
$locations = get_nav_menu_locations();
print_r ($locations);

Basically on every page the
Code:
$locations
is an empty array even though I've created and saved the menu. Was hoping to create menus and having the name of it in a custom field so every page can have it's own menu (or nothing when left empty or default menu when custom field not provided).

Guess I'm not getting the way wordpress intends the user to use it, maybe it's just a checkbox somewhere. I did notice that when I check the box
Code:
Main Menu
under Appearance -> Menus the array returned isn't empty but
Code:
$locations[ $menu_name ]
is not set.

Using wordpress 3.6.1 with a modded blankslate theme.

<strong>[UPDATE]</strong>
The functions.php is hardly changed and the register_nav_menus is set with the following parameter:

Code:
array( 'main-menu' =&gt; __( 'Main Menu', 'blankslate' ) )

I guess that's where the
Code:
Main Menu
checkbox in Appearance -> Menus on the Dashboard comes from. Commenting out this line makes
Code:
Menus
disappear all together.