WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

I have a parent page called "About". This page has three child pages "Members", "Information", "Contact".

I want to list all the child-pages on all four pages, also the parent-page. So right now I have this which lists all the child-pages only on the parent-page.

        if ( !$post->post_parent ) {
            echo '<ul id="subpages" class="wrapper">';
                wp_list_pages("title_li=&child_of=".$post->ID."&link_before=— ");
            echo '</ul>';

But I want all the pages also listed on each individual child page.

How do I do that?

share|improve this question
up vote 1 down vote accepted

This function will do the trick, it displays the child pages of the current page, but if there are no child pages, it displays the child pages of the parent page, and a link back to the parent page.

 * @brief: Shows the subpages of the current page, or
 *         the adjacent sibling pages.
function show_subpages(){

    global $post;
    $subpages = wp_list_pages( array(
        'child_of'=> ( $post->post_parent == 0 ? $post->ID : $post->post_parent)
    if ( !empty($subpages) ) {

        if ( $post->post_parent != 0 ) {
            echo '<p class="parent-link"><em>'. __('Back to') .' <a href="'. get_permalink($post->post_parent) .'">'. get_the_title($post->post_parent) .'</em></a><p>';
        echo '<ul>';
        echo $subpages;
        echo '</ul>';
    } else {
        echo 'no subpages';

You may need to place this in the main loop

share|improve this answer

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.