Support » Fixing WordPress » Display grandchild pages ONLY when onchild 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)

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    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.

Viewing 1 replies (of 1 total)
  • Code I am currently using from the codex

    <?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 } ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Display grandchild pages ONLY when onchild page’ is closed to new replies.