Support » Fixing WordPress » Sub menu is breaking and showing on all pages

  • Resolved DesignLoud


    if you go to you will see that I am trying to align my sub-menu (company, owners) under the main menu instead of the traditional drop down. Heres the problem I am having, the sub menu is displaying on all pages (like it is supposed to) but what I want it to do is only display when the parent page is current (selected). So you wouldnt see the sub-menu when your on the other pages but you will see the sub menu when you are on the About page, company page or owners page. I need a little assistance in the php side of this so it pretty much hides when users are on other pages except those three. Any ideas?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Wrap the associated php of your sub menu in is_home, a conditional tag.

    I dont know what I should put after this:

        if is_page (array('about','company','owners')) {

    I guess I am asking for an example I could work off of. 😉

    Any help on this would be very much appreciated. I cannot find anything similar to this on the forums or google. Kind of at a loss here and my lack oh php knowledge doesnt help 😉

    seriously, anyone? please help me resolve this.. Sorry to keep replying to my own thread but I have noticed that these just get buried in the forums the more posts it has.. Seems simple, but it is beyond my experience anyone?

    Swanson what do you mean by

    Wrap the associated php of your sub menu in is_home, a conditional tag.

    can you provide me an example on how to do this? Sorry to be a bother but I am crunched for time on getting this done and this seems to be one of my last few holdups. Thanks

    Anyone else who might know how to do this please feel free to chime in.

    It looks like you got this figured out? Unless I’m totally not understanding what you are wanting to do.

    I only see the submenu when going to the About page or when visiting the Owners link after clicking on About.

    Ya, I had to do it via CSS in meantime, which I knew I could do all along but from my understanding search engines (specifically google) dont like the whole ‘display:none’ so I was looking for a way to handle this through php..

    Still interested if you have any suggestions but in the mean time I guess this will do.

    How do you have your menus setup? If they are custom menus that you can setup through the Appearance->Menus page than you could just create the second submenu as its own menu and then use the code above to determine which pages you are on and display the second submenu.

    <?php if ( is_page( array( 'about', 'company', 'owners' ) )
         wp_nav_menu( array('menu' => 'Submenu' ));

    You would place this code where you want the submenu to appear in your theme. You could also just hard code the HTML into there as well if you don’t or haven’t setup custom menus.

    <?php if ( is_page( array( 'about', 'company', 'owners' ) ) ?>
         <li class="submenu"><a href="">Link 1</a></li>
         <li class="submenu"><a href="">Link 2</a></li>
    <?php ; ?>

    Or you could just stick with display: none; and CSS as most submenus utilize this particular method.

    Thanks Jarret, I appreciate your feedback!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Sub menu is breaking and showing on all pages’ is closed to new replies.