• Hey,

    I am trying to use different top menus on different pages for a website that is an umbrella website which has a homepage and then breaks out into 4 company websites all under the same domain.

    Each of the 4 websites needs to have a separate nav menu so 4 menus total.

    Currently I’m trying this:

    add to functions.php:

    register_nav_menus( array(
    ‘section1’ => __( ‘Section 1 Menu’, ‘clinico’),
    ‘section2’ => __( ‘Section 2 Menu’, ‘clinico’),
    ‘section3’ => __( ‘Section 3 Menu’, ‘clinico’),
    ‘section4’ => __( ‘Section 4 Menu’, ‘clinico’),
    ) );
    ?>

    add into header.php between the <nav> tags:

    $sectmenu=get_post_meta($post->ID, ‘section’, true);
    switch ($sectmenu):
    case “1”:
    wp_nav_menu( array( ‘theme_location’ => ‘section1’, ‘menu_class’ => ‘main-menu’ ) );
    break;
    case “2”:
    wp_nav_menu( array( ‘theme_location’ => ‘section2’, ‘menu_class’ => ‘main-menu’ ) );
    break;
    case “3”:
    wp_nav_menu( array( ‘theme_location’ => ‘section3’, ‘menu_class’ => ‘main-menu’ ) );
    break;
    case “4”:
    wp_nav_menu( array( ‘theme_location’ => ‘section4’, ‘menu_class’ => ‘main-menu’ ) );
    break;

    </nav><!– #access –>

    Then I add Custom Field ‘section’ to each page and give it a value of 1, 2, 3 or 4.

    This has been working great for section 1 and 2. However, pages I try to add as section 3 or 4 are causing the page to show up completely blank.

    Any suggestions?

  • The topic ‘Different 'Top Menus' on different pages’ is closed to new replies.