[resolved] Hiding sub-menus unless parent is clicked (11 posts)

  1. Webb7
    Posted 1 year ago #

    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() ) { ?>
                $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; ?>
                <?php } } ?></li></ul>
  2. kmessinger
    Forum Moderator
    Posted 1 year ago #

    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

  3. Webb7
    Posted 1 year ago #

    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.

  4. kmessinger
    Forum Moderator
    Posted 1 year ago #

    Is it supposed to be under Digital Signage?

    Does it work with the default WordPress theme?

  5. Webb7
    Posted 1 year ago #

    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.

  6. kmessinger
    Forum Moderator
    Posted 1 year ago #

    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.

  7. Webb7
    Posted 1 year ago #

    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

    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

  8. kmessinger
    Forum Moderator
    Posted 1 year ago #

    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.

  9. Webb7
    Posted 1 year ago #

    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

  10. kmessinger
    Forum Moderator
    Posted 1 year ago #

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

  11. Webb7
    Posted 1 year ago #

    I'm using a custom CSS.

Topic Closed

This topic has been closed to new replies.

About this Topic