• I am working on a template and have put together a loop to pull in the content from the current page’s children using get_pages. I found the code via this post: http://wordpress.org/support/topic/get_pages-how-to-disable-grandchildren?replies=6

    Here is the code I have to pull in the content from the sub pages/ child pages:

    <?php
      $pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc&parent='.$post->ID);
       $count = 0;
    foreach($pages as $page)
    {
    $content = $page->post_content;
    $content = apply_filters('the_content', $content)
    ?>
    <div class="child-content">
    <h2><?php echo $page->post_title ?></h2>
    <p><?php echo $page->post_content ?></p>
    </div>

    However I would like to include the content from the grandchild as a separate piece. So that it would result with something like this:

    <div class="child-content">
    <!-- This displays content from a child of the current page -->
    <h2><?php echo $page->post_title ?></h2>
    <p><?php echo $page->post_content ?></p>
    </div>
    
    <div class="GRANDchild-content">
    <!-- This displays content from the child of the content above -->
    <h2><?php echo $page->post_title ?></h2>
    <p><?php echo $page->post_content ?></p>
    </div>

    Can someone point me in the right direction?

  • The topic ‘DIsplay content from child and grandchild pages on parent page’ is closed to new replies.