I have 4 different menus on my website.
Right now I'm using the solution to a problem I posted here in order for the menu to display using the CSS framework I'm making use of.
Each of these menus has a number of child pages, and on these child pages I'd like to display the corresponding menu. For example, the About Us children would only show the about us menu, the contact children would only show the contact us menu.
My functions.php showing the menus is:
<?php
function register_my_menus() {
register_nav_menus(
array(
'about-menu' => __( 'About Us Menu' ),
'how-menu' => __( 'How Do I Menu' ),
'services-menu' => __( 'Our Services Menu' ),
'online-menu' => __( 'Do It Online Menu' )
)
);
}
add_action( 'init', 'register_my_menus' );
?>
In my mind I imagine it to be a script in the header.php that would just have a series of if statements.
I appreciate your help.
EDIT: I've actually solved this by using a series of if statements and using a php include within the pages.
For anyone interested, I've used the solution posted above, with the following code:
<?php
if ( $post->post_parent == '1' || is_page(1) ) {
$menu_name = 'about-menu';
// and so on..
}
elseif ( $post->post_parent == '2' || is_page(2) ) {
$menu_name = 'contact-menu';
// and so on..
}
?>
Granted it may not be the best way of doing it, what with having a great deal of repeated code, but it works for me, and I hope it can benefit others in the future.