Support » Fixing WordPress » Displaying Grandchild pages only when on child page

  • 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]

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Displaying Grandchild pages only when on child page’ is closed to new replies.