Grandparent Pages

  • Unknown's avatar

    I am using WP as a CMS.

    I have a Local Nav relevant to the current page I wish to populate with Child pages. I want Grandchild pages to exist for each Child page.

    All I want is the general functionality you see on nearly any large site with 3 tiers. I want all the Grandparents children to show when in that Grandparent, and when a child is selected, only have the grandchildren under that selected parent to show.

    Using this code, it does not show the grandchildren.

    <ul>
     <?php //if current post's parent is not 0, track back up the chain until parent is zero
    //then use that as the value passed in for child_of
    $emp_parent_post = 1;
    $emp_testingpage = $post->ID;
    //print $emp_testingpage." ";
    while ($emp_parent_post <> 0){
    $emp_parent_post = $wpdb->get_var("SELECT post_parent FROM $wpdb->posts WHERE ID = $emp_testingpage");
    //print $emp_parent_post." ";
    if ($emp_parent_post <> 0) $emp_testingpage = $emp_parent_post;
    //print $emp_testingpage." ";
    }
    
    ?>
    <?php
    wp_list_pages("title_li=&Sub-Pages&depth=1&child_of=" . $emp_testingpage);
    ?>
    
    </ul>

    Affecting the depth will indeed show the grandchildren, but I don’t want to show them unless their parent is selected.

  • Unknown's avatar

    Wrong site I’m afraid. You need to be over at http://wordpress.org That’s the support site for the software. These forums are for the blogs hosted here at wp.com and we don’t have file level access.

  • The topic ‘Grandparent Pages’ is closed to new replies.