Take a look at the primary nav on http://fhnsports.com/. Right now that’s a regular WordPress custom menu, and all the menu items are regular Pages, but I need to recreate it in a different way.
In our new system all those Sports page are custom content type elements, and Editors will NOT have access to edit them. I want to build a menu where everything under the HQ nav item is Pages, automatically added as they come into existence. Then the sports areas are built from my custom content type, existing in the menu based on criteria I determine (does the school have that sport? etc).
It’s almost like I want to combine the results of two wp_nav_menu calls into one menu.
I’ve considered doing exactly that, hardcoding the menu wrapper, and then simply running the two wp_nav_menu calls inside that.
I know WordPress can automatically add pages to a custom menu, but can we have one where it’ll automatically add posts from a custom content type?
2 thoughts on “WordPress Custom menu”
As far as I see it, you should be good to go with with `get_posts` or `get_pages` and a custom Walker. Create a Custom Link that’s titled “#HOOKED_MENU#” for example, so you can easily detect it inside a walker. You’ll have to displace the default $walker, probably via the some of the available hooks, and have the walker start() or end() element, detect an $item->title == “#HOOKED_POSTS#”, and further inject the get_posts for that particular CPT.
I’ve dabbled around somewhere close a couple of days ago http://codeseekah.com/2012/03/01/custom-post-type-archives-in-wordpress-menus-2/ you can get some ideas and pointers there.
Let me know how it goes via twitter (@soulseekah, unless I get an e-mail for your response to the comment) please. I’d love to know how you end up solving this quite interesting problem. Should be a much easier way that I’m describing.
Best of luck.
I daresay you may actually implement checkboxes like here http://wordpress.org/extend/plugins/cpt-archives-in-nav-menus/screenshots/ for the backend, and have the functionality to always pull in children as described above.
I think you can actually hook into http://adambrown.info/p/wp_hooks/hook/wp_nav_menu_items and setup add more items to the menu by get_posts, and set parent_ids for them all… I’ll be experimenting see if I can come up with something good.