Support » Fixing WordPress » Display fellow child pages of relative parent

  • I’ve got a hierarchy of pages, somewhat like this:

    Parent 1
    Parent 2
    Parent 3
    –Child 1
    –Child 2
    —-Grand Child 1
    —-Grand Child 2
    —-Grand Child 3
    –Child 3
    Parent 4

    My issue is, while on Grand Child Pages 1-3, I want to show fellow sibling pages in a “menu” when they exist, and when you’re on the Child page.

    For example, if I’m on Child 2, I would see:

    — Child 2
    —- Grand Child 1
    —- Grand Child 2
    —- Grand Child 3

    And if I were on Grand Child 2 I would see the same thing:

    — Child 2
    —- Grand Child 1
    —- Grand Child 2
    —- Grand Child 3

    I’ve been using:

    <?php if($post->post_parent){ ?>
    <div class="interior-nav">
    <?php
      $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
      if ($children) { ?>
         <ul class="inner-nav">
            <?php echo $children; ?>
         </ul>
      <?php } ?>
    </div>
    <?php } else { echo 'do nothing, you have no children or grand children'; } ?>

    It works when you’re on the Child page, i.e. it shows the grand children, but then when you get to a grand child page, you don’t see “fellow” children or the relative parent.

    Annnnnnd now I need coffee. haha that was a mouthful.

    Thanks for any tips in advance!

  • The topic ‘Display fellow child pages of relative parent’ is closed to new replies.