Okay
  Public Ticket #252780
Differents menus on differents pages
Closed

Comments

  • Stef started the conversation

    Hi,

    I'm creating a web site with 2 differents landing pages with 2 buttons who leads to two differents pages, and i would like to have differents menu and those pages !

    Can you help me ?

  •  1
    Ian replied

    You need to do two things, 

    1) Register a new menu

    2) Add conditional logic to you header to display that menu

    I used this to display a different menu when users are logged in;  In your case, you just need to tweak the logic to have context of the current page. 

    First I registered a second menu by updated the Nave menu array (I just added the 'top_nav_loggedin' below. 

     if ( function_exists( 'register_nav_menus' ) ) {

    register_nav_menus(

    array(

    'top_nav' => 'Top Navigation Menu',

    'top_nav_loggedin' => 'Top Navigation Menu Logged In',

    'secondary_nav' => 'Secondary Navigation Menu <br /> <small>Will only display if applicable header layout is selected <a href="'. admin_url('?page=redux_options&tab=4') .'">here</a>.</small>'

    )

    );

    }

    Next I added the conditional logic in header.php.  

    <ul>

    <?php

    if(has_nav_menu('top_nav')) {

    if ( is_user_logged_in() ) {

    wp_nav_menu( array('walker' => new Nectar_Arrow_Walker_Nav_Menu, 'theme_location' => 'top_nav_loggedin', 'container' => '', 'items_wrap' => '%3$s' ) ); }

    else {

    wp_nav_menu( array('walker' => new Nectar_Arrow_Walker_Nav_Menu, 'theme_location' => 'top_nav', 'container' => '', 'items_wrap' => '%3$s' ) ); }

    }

    else {

    echo '<li><a href="">No menu assigned!</a></li>';

    }

    ?>

    <li id="search-btn"><div><a href=""><span aria-hidden="true"></span></a></div></li>

    </ul>

    Once you have done this, just customize your menu inside the Wordpress admin panel to whatever you want.  

  •  8,472
    Tahir replied

    Hey Ian!

    Thanks for sharing ill add it to the FAQ . 

    Cheers


    ThemeNectar Support Team