List Parent and Children
-
working on a site where the user wants a side menu “secondary navigation”
What I need is to list the PARENT and the Children for the current page, even if it is a child and not the parent.
So for instance I need something like
PARENT
child1
child2
child3That displays just like this even if you’re on Child3 page.
Hope this makes sense.
I looked up some stuff but I couldnt get it to workI tried this
<?php // Grab Correct Menu if ($post->post_parent == 0): $menu_id = $post->ID; $menu_title = $post->post_title; else: $menu_id = $post->post_parent; $parent = get_post($menu_id); $menu_title = $parent->post_title; endif; ?>and
<div class="secondnav"> <h3 class="secondHeader"> <a href="?page_id=<?php echo $menu_id; ?>"> <?php echo $menu_title; ?> </a> </h3> <ul class="secondMenu"> <?php wp_list_pages('title_li=&child_of=' . $menu_id); ?> </ul> </div>but I’m getting a list of all the pages.
Viewing 15 replies - 1 through 15 (of 15 total)
Viewing 15 replies - 1 through 15 (of 15 total)
The topic ‘List Parent and Children’ is closed to new replies.