Support » Fixing WordPress » Hiding sub-menus unless parent is clicked

  • Resolved Webb7

    (@webb7)


    Hi, I want the sub pages of parent pages to be hidden unless the parent page is clicked. I’ve been looking around all day for a fix but couldn’t find anything to help me out on it.
    Website This is the page which I am trying to do it on. Here is the coding which I have, what do I need to do to the code in order to get this working?

    <div class="column-layout side-nav">
                <?php if ( is_page() ) { ?>
                <?php
                if($post->post_parent)
                $children = wp_list_pages('sort_column=menu_order&title_li=&child_of='.$post->post_parent.'&echo=0'); else
                $children = wp_list_pages('sort_column=menu_order&title_li=&child_of='.$post->ID.'&echo=0');
                if ($children) { ?>
                <?php $permalink = get_permalink($post->post_parent); ?>
    
                <ul><li><a href="<?php echo $permalink; ?>"><?php
                $parent_title = get_the_title($post->post_parent);
                echo $parent_title;
                ?></a><ul class="sub-menu">
                <?php echo $children; ?>
                </ul>
                <?php } } ?></li></ul>
            </div>

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator kmessinger

    (@kmessinger)

    Where is it not working? The ones I checked seemed ok.

    Also you need to upgrade your version of WordPress ASAP.

    A custom theme will be hard to find support for as we normally only support themes from wordpress.org

    The IP TV is the one I currently have visible but I want it to not be visible until you click on its parents page.

    Moderator kmessinger

    (@kmessinger)

    Is it supposed to be under Digital Signage?

    Does it work with the default WordPress theme?

    Yes, the IP TV is the one which I want to appear when digital signage is clicked and I haven’t tried it in the default theme.

    Moderator kmessinger

    (@kmessinger)

    On the dashboard>appearance>menus you should be able to drag IP TV under and a little to the right of digital signage. If you cannot then you need to see if you can with the default theme.

    Yeah I can do that however the page is still visible in the menu. I want it so that IP TV (and other sub pages) only appear when their parent page is clicked.

    This is pretty much what I want:
    Audio Visual Solutions
    Meeting rooms and boardrooms
    Digital signage
    Collaborative Solutions
    etc….

    But when I click onto digital signage then it will display the sub pages too such as:
    Digital Signage
    – IP TV
    – Video Wall
    – Common Space
    Collaborative Solutions

    Moderator kmessinger

    (@kmessinger)

    Looks like Digital Signage is the only one with sub-menu’s.

    You need to disable all plugins and try to get the results you want with the default theme. We want to rule out plugin or theme problems as best we can.

    You also need to upgrade. 3.4.2 is over 1 year old.

    Solved all I had to do was add this:

    .sub-menu { display: none; }
    .current_page_item .sub-menu, .current_page_parent .sub-menu { display: block; }

    at the end of my CSS

    Moderator kmessinger

    (@kmessinger)

    Great. Are you using a child theme for css changes? That way you won’t loose them when you upgrade.

    I’m using a custom CSS.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Hiding sub-menus unless parent is clicked’ is closed to new replies.