Sub-menu issue
-
I got my menu (left side) to display the relevant submenu when the parent was click on. But when you click onto that sub menu, the rest disappears.
When clicked on the parent page it will list the sub pages below but when I click onto one of those sub pages, then they will no longer be there.
Here is the coding which I’m using:
<?php if(!$post->post_parent){ // will display the subpages of this top level page $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); }else{ // diplays only the subpages of parent level //$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); if($post->ancestors) { // now you can get the the top ID of this page // wp is putting the ids DESC, thats why the top level ID is the last one $ancestors = end($post->ancestors); $children = wp_list_pages("title_li=&child_of=".$ancestors."&echo=0"); // you will always get the whole subpages list } } if ($children) { ?> <ul> <?php echo $children; ?> </ul> <?php } ?>
For my CSS:
.page_item .children { display: none; } .current_page_item .children { display: block; }
Anyone know how I can get it successfully work so that when I’m on the sub page it will display the sub pages under that parent.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Sub-menu issue’ is closed to new replies.