• Hello everyone,

    I hope someone knows about it and could help me.

    I have a Menu1 (main menu) with buttons “Home, About Us, Categories, Contacts”.

    “Categories” menu has the options “Category A” and “Category B”.

    When I click over “Category A” I go to “Category A” page, but I would like that the Menu1 changes to Menu2 (Menu2=”Home, Description Cat A, Events Cat A”).

    And when I go to “Category B” page I would like that the Menu1 changes to Menu3 (Menu3=”Home, Description Cat B, Events Cat B”).

    Is there a plugin or a way to use different menus depending the page/post as I describe above?

    PS: I’m using Weaver 2.2.6 theme, WordPress version 3.2.1

    Many thanks in advance.

    Regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Use different menu depending page/post’ is closed to new replies.