WordPress.org

Ready to get started?Download WordPress

Forums

[closed] Displaying Grandchild pages only when on child page (2 posts)

  1. rikardo85
    Member
    Posted 2 years ago #

    Hello,

    I currently have 3 levels of navigation.
    I can display the parent, child and grandchild pages fine using the code form the codex (below)

    <?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) { ?>
    
        <?php echo $children; ?> 
    
    <?php } ?>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button.]

    However I want the grandchild pages to display only when I have selected the child page (see below)

    Home
    About
    Service
    - child page 1
    - Grandchild page 1
    - Grandchild page 2
    - Grandchild page 3
    - child page 2
    - child page 3
    Portfolio
    Contact

    All child pages should still be on display when I am on a Grandchild page.

    Hope you can help.

    [closed as duplicate of: http://wordpress.org/support/topic/display-grandchild-pages-only-when-onchild-page?replies=2 - continue with the original topic]

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    Have you reviewed the various examples in Listing sub-Pages?

Topic Closed

This topic has been closed to new replies.

About this Topic