Hi,
The easiest way of accomplishing this is to:
1. Register your menus (or the additional ones) using register_nav_menus. This is usually done from functions.php.
2. Create menus for the registered locations from Admin Panel -> Appearance -> Menus.
3. Call your menus conditionally using wp_nav_menu, like so:
if ( is_category('Category A') ) {
wp_nav_menu(array(
'theme_location' => 'cat_a_location'
));
}
elseif (is_category('Category B') ) {
wp_nav_menu(array(
'theme_location' => 'cat_b_location'
));
}
else {
wp_nav_menu(array(
'theme_location' => 'main_location'
));
}
Thread Starter
Aloris
(@aloris)
Hello Marventus,
Many thanks for your reply and help.
I’ve been trying and I’ve been able to complete step 1 and 2, but I have problems with step 3 so far.
The file that controls the men navigation in weaver 2.2.6 is nav-bottom.php.
The original part where I think I have to modify is:
if (weaver_getopt('ttw_use_superfish'))
wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary', 'menu_class' => 'sf-menu', 'fallback_cb' => 'weaver_page_menu' ) );
else
wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) );
I’ve modified following your code, but instead of use is_category(), I’ve used is_page(). I get the 2nd menu in the page I want, but appear all buttons vertically and not horizontally as the main menu.
I’ve modified as below:
if (weaver_getopt('ttw_use_superfish'))
if ( is_page('Category A') ) {wp_nav_menu(array( 'theme_location' => 'cat-a-menu') );}
elseif (is_page('Category B') ) {wp_nav_menu(array('theme_location' => 'cat_b_location'));}
else {wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary', 'menu_class' => 'sf-menu', 'fallback_cb' => 'weaver_page_menu' ) );}
else
wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) );
May you help me to fix this?
Thanks in advance