WordPress.org

Ready to get started?Download WordPress

Forums

Adding custom menus to pages (2 posts)

  1. Elaine Griffin
    Member
    Posted 2 years ago #

    Hey all,
    I am working with a client who wants custom menus for four main pages of their site, One Earth Solutions. Using a child theme of Twenty Eleven, I have registered and set the menus up, but I'm struggling when it comes to assigning the menu's to pages. Here is my code in my header.php file:

    <?php
    if (is_page('permaculture')){
    wp_nav_menu(array('menu'=>'permaculture' ));
    } elseif (is_page('farm')) {
    wp_nav_menu(array('menu'=>'farm' ));
    } elseif(is_page('energy')){
    wp_nav_menu(array('menu'=>'energy' ));
    } elseif (is_page('home')) {
    wp_nav_menu(array('menu'=>'primary' ));
    }
    ?>

    I can't figure out what I'm missing - any help would be appreciated!

    [Moderator Note: Please post code or markup snippets between backticks or use the code button.]

  2. Elaine Griffin
    Member
    Posted 2 years ago #

    Okay, well, my code is now in the sidebar.php file, instead of the header and I changed it a little, and added code to catch the sub-pages:

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    But now on many pages there is more than one navigation bar, and they are all (except the home page) are showing the farm menu. Well, except the actual farm page.
    An example:
    http://www.one-earth-solutions.com/energy/
    And the sub pages are not picking up the correct menus. Any help?
    Thx!

    [No bumping, thank you.]

Topic Closed

This topic has been closed to new replies.

About this Topic