Hiding sub-menus unless parent is clicked
-
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)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘Hiding sub-menus unless parent is clicked’ is closed to new replies.