Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to figure out how to display a menu that has been created, but without having to assign the menu to a theme location.

From what I can tell, you have to assign a menu to a theme menu location and then wp_nav_menu calls a menu from whatever location you want.

I don't want to have to assign a menu to a theme location. Instead, I want to be able to create a menu and then query it within my theme... regardless of theme location.

I've created a plugin for myself that uses wp_get_nav_menus to list all of the menus I've created... I can then assign any menu to a page/post. Now, I'm stuck trying to figure out how to retrieve that specific menu... again, not menu theme location.

Anyone?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

wp_nav_menu takes an optional argument called menu, which will fetch any menu by name, slug or ID.

If you just want post objects (or anything but the menu HTML), wp_get_nav_menus is the way to go. Otherwise, use wp_nav_menu. If you need it to return the menu HTML instead of echoing, there's an argument for that as well: echo.

share|improve this answer
    
How in the world did I miss that? I guess I got sidetracked by "menu_id" ... which seems to only deal with menus within a theme location. Thanks a lot, Christopher. –  dcolumbus Oct 10 '11 at 14:52
add comment

Well, it looks like I found what I need:

http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items

I find it odd that wp_get_nav_menus isn't documented in the Codex.

share|improve this answer
add comment

Your Answer

 
discard

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

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