Forums

[resolved] Adding another level so as not to display child of 2nd parent (1 post)

  1. petelcj
    Member
    Posted 6 months ago #

    Hi

    I've run into a small problem with the sidenav of a site I'm working on.

    Class page 1 (parent)
    - Page 2 (child)
    - Page 3 (child) (parent)
    ---- Page 4 (child)
    ---- Page 5 (child)

    The nav at the moment shows ALL the pages under Class page 1 Basically I only want to show Class page 1 (parent), Page 2 (child), Page 3 (child) in the nav and I want to hide - Pages 4 & 5 from the navigation unless I am in page 3. Below is the code I am currently using. Is there anyway to amend this code to do what I want or is there a solution somewhere you could point me in the direction of?

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

    Any help would be much appreciated.

    Thanks

Reply

You must log in to post.

About this Topic