axessJosh
asked on
Get menu name from parent page
I'd like to keep the amount of page templates to a minimum in a theme I am creating but would like to add the ability to have secondary menus on a page based on which page the user is on.
For instance, we'll always have the primary navigation at the top of the page.
But I'd like to build separate menus that the user can custom create in the appearance >> menus area.
I'd then like to add some dynamic code in my page.php template that determines which parent page we are on, then displays any extra navigation if there is one or goes to a default otherwise.
I'm looking for some pointers on how to select the secondary navigation menus because I am not adding them into a location in the menus area. Mainly, needing to create a variable for the menu name, then use that variable to select a menu with wp_nav_menu();
For instance, we'll always have the primary navigation at the top of the page.
But I'd like to build separate menus that the user can custom create in the appearance >> menus area.
I'd then like to add some dynamic code in my page.php template that determines which parent page we are on, then displays any extra navigation if there is one or goes to a default otherwise.
I'm looking for some pointers on how to select the secondary navigation menus because I am not adding them into a location in the menus area. Mainly, needing to create a variable for the menu name, then use that variable to select a menu with wp_nav_menu();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks JRM,
I was trying to avoid using custom fields but you are correct, that is probably the simplest way to handle it and not have to deal with getting into the code with future updates.
This may need a second question, but any thoughts on how to display the menu title with the menu?
I was trying to avoid using custom fields but you are correct, that is probably the simplest way to handle it and not have to deal with getting into the code with future updates.
This may need a second question, but any thoughts on how to display the menu title with the menu?
Thanks for the points, I would have split the points between me and omniunlimited though.
You could try this for getting the title:
http://wordpress.org/support/topic/display-title-attribute-in-menu
You could try this for getting the title:
http://wordpress.org/support/topic/display-title-attribute-in-menu
Open in new window