Populating Page with Child and Grandchildren
-
I don’t know the best way to describe my problem the topic title is true but it’s a little more complex than that. I’ve actually been able to populate using:
<?php $mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) ); foreach( $mypages as $page ) { $content = $page->post_content; if ( ! $content ) // Check for empty page continue; $content = apply_filters( 'the_content', $content ); ?> <h2><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h2> <div class="entry"><?php echo $content; ?></div> <?php } ?>
The problem I’m running into is that this isn’t what I was looking for. I really need to list the Child Page Title and immediately below that, list the first 5 Grandchildren (first one with the_thumbnail) of that Child Page with their own look.
With the code I have above, it just treats everything exactly the same. I’ve even designed a little mockup if my terminology is not up to snuff.
Am I going about this the right way? I’ve seen this done with posts/categories but they lack the power of templates that pages have.
- The topic ‘Populating Page with Child and Grandchildren’ is closed to new replies.