• The CODEX code which I have in place doesn’t seem to work as expected. For the following heirarchy:

    Classes
    -1st Grade
    — Schedule
    — Gallery
    -2nd Grade
    — Homework
    — Blog
    -3rd Grade
    — Student Work
    — Goals

    When I’m on the 1st Grade page, I want the nav menu to display only that page’s children Schedule and Gallery. When I’m on either Schedule or Gallery, I still only want to display those pages siblings: Schedule and Gallery.

    The codex code I’m using is:

    <?php
    if($post->post_parent) //if we're on a child page, correct?
     $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
    
    else // or we're on the parent??
     $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
    
    if ($children) { ?>
    <nav class="classnav widget">
     <ul class="nav unstyled class-links">
      <?php echo $children; ?>
     </ul>
    </nav>
    <?php } ?>

    Currently, when on the 1st Grade page using the above code, I get a nav menu with all of it’s siblings (2nd, 3rd Grade) and those siblings children as well. When on the Schedule or Gallery page however, the menu displays their expected sibling pages.

    I’ve perused numerous posts about this topic but haven’t found anything that matched my situation or worked. I would REALLY appreciate any help! Thanks in advance.

    [ Please do not bump, that’s not permitted here. ]

  • The topic ‘wp_list_pages to show parent's children, and children's siblings’ is closed to new replies.