• 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.]

Viewing 1 replies (of 1 total)
  • Thread Starter Elaine Griffin

    (@elaine-griffin)

    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:
    https://www.one-earth-solutions.com/energy/
    And the sub pages are not picking up the correct menus. Any help?
    Thx!

    [No bumping, thank you.]

Viewing 1 replies (of 1 total)
  • The topic ‘Adding custom menus to pages’ is closed to new replies.