wp_list_pages Parent AND Children Pages
-
Hello,
So I’ve been sitting here throwing everything I can at solving this and I cannot manage to get it done. I am pretty newb @ PHP but I am pretty good @ reading it and putting things where they need to be to work right. However, I cannot figure this one out: I am trying to make a navigation that will show both the Parent AND Children pages for a given parent page.
Example: On the main navigation you click Parent 1. On the left sidebar this is what I want to display:
Parent 1
Child 1
Child 2
Child 3But what I can only accomplish is:
Child 1
Child 2
Child 3With this code (that I got from the codex):
<?php if($post->post_parent) $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); if ($children) { ?> <ul> <?php echo $children; ?> </ul> <?php } ?>
I also want to emphasize: I only want to show the parent and sub pages for the current parent page I am on. So if I click on Parent 1, I don’t want to show anything from Parent 2, Parent 3, etc.
Thanks for the reading and the help!
Dave
- The topic ‘wp_list_pages Parent AND Children Pages’ is closed to new replies.