WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Sub menu is breaking and showing on all pages (10 posts)

  1. DesignLoud
    Member
    Posted 2 years ago #

    if you go to http://itestwebpageshere.biz 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?

  2. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

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

  3. DesignLoud
    Member
    Posted 2 years ago #

    I dont know what I should put after this:

    <?php
        if is_page (array('about','company','owners')) {
         WHAT DO I PUT HERE
        }else{
        AND WHAT DO I PUT HERE
        }
    ?>

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

  4. DesignLoud
    Member
    Posted 2 years ago #

    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 ;)

  5. DesignLoud
    Member
    Posted 2 years ago #

    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?

  6. DesignLoud
    Member
    Posted 2 years ago #

    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.

  7. JarretC
    Member
    Posted 2 years ago #

    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.

  8. DesignLoud
    Member
    Posted 2 years ago #

    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.

  9. JarretC
    Member
    Posted 2 years ago #

    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.

  10. DesignLoud
    Member
    Posted 2 years ago #

    Thanks Jarret, I appreciate your feedback!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags