1

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?

2

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.

  • 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
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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