WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On my site I have a number of parent pages with associated child pages. How can I show all the child pages of one particular parent when a visitor is either on the parent page or one of it's children?

For example;

If someone clicks onto the "Story" parent page, they'll see a list of "story" child pages in the sidebar (As well as a link to the parent page). Then if they click through to one of those child pages, they'll still be able to see the list in the sidebar

share|improve this question
up vote 1 down vote accepted
    Add this code in sidebar.php.this code will help you.                    

                        global $post;
                        $parent_id  = $post->post_parent; 
                        echo '<h1 class="entry-title">'.$parent_post->post_title.'</h1>';
                            echo '<ul>';
                            $children = wp_list_pages('title_li=&child_of=' . $parent_id . '&echo=0');
                            if ($children) {
                            echo $children;
                            echo '</ul>';
                         } else { 
                        echo '<ul>';
                        $page =$post->ID;
                        $children = wp_list_pages('title_li=&child_of=' . $page . '&echo=0');
                            if ($children) { 
                            echo $children;
                        echo '</ul>';
share|improve this answer
Perfect! Thank you – Dean Elliott Oct 9 '12 at 12:42

Depends on how you want to do it, but you can use the Sub Pages widget plugin


It hasn't been updated for a long while, but seems to be working fine on a 3.4.2 install of WP.

share|improve this answer
I can't really use a plugin (It's for a client) so it'd need to be hardcoded – Dean Elliott Oct 9 '12 at 10:45
Ok, well in a nutshell, you need to get the parent page of your current page ($page->page_parent) and then pass this ID to wp_list_pages() with the child_of parameter being the page_parent you found earlier. – anu Oct 9 '12 at 10:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.