• Testing Site: http://www.indysouthportdental.com.php5-1.ord1-1.websitetestlink.com

    I only want to display the children of parent in the sidebar when viewing any pages within the parent.

    For example, Oral Health has 10 child pages. Some of those child (Treatment for example) pages have child pages (grandchildren of Oral Health).

    Even if I’m on a grandchild page, I still want to list the only the child pages of the parent.

    This is the code I’m using

    <?php
    if($post->post_parent)
    $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&depth=1");
    else
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1");
    if ($children) { ?>
    <h2>Oral Health</h2>
    <ul>
    <?php echo $children; ?>
    </ul>
    <?php } ?>

    This code diplays the related grandchild pages when on any grandchild page rather than the child pages.

    (hope that all makes sense…)

  • The topic ‘Sub Navigation in Sidebar’ is closed to new replies.