treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Show different Nav Menu on specific pages wordpress..

  • iv looked around and even found the couple lines of php for this but i still cant peice it together how i need it

    pretty much i have 3 pages, these pages should all display "menu2" if the visitor is not on any of the 3 particular pages, then they should see "menu1" i now thats a pretty straight forward bit of code . i think the heat is getting to me, can anyone help me out?

    thank you
  • here, i am not sure, but it might help
  • You could use two templates for this. Let's say they are called template1.php and template2.php. Three pages that use menu1 use template1, and set the other pages to use template2.

    I assume you will put the menu in your header. In there, you can then use this code:

    <div id="menu">
    <?php
    if ( is_page_template('template1.php') ) {
    // This is where you put the code for menu1.
    } else {
    // This is where you put the code for menu2.
    }
    ?>
    </div>
    If you're creating the menus in Wordpress, then it would end up something like this:

    <div id="menu">
    <?php
    if ( is_page_template('template1.php') ) {
    wp_nav_menu( array('menu' => 'Menu1' ));
    } else {
    wp_nav_menu( array('menu' => 'Menu2' ));
    }
    ?>
    </div>

  • the second method worked perfect thank you! :-D

    just gotta style them now uhg..