Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Aron Macarow
Aron Macarow
1,936 Points

Display child page content on parent page?

I currently have child pages titled by year. Each child page contains an ACF repeater with text/image content.

All Artwork (parent page)

  • 2017 (child page)
  • 2016 (child page)
  • 2015 (child page) ... etc.

I'd like to have a parent page display specific content from all of its child pages in descending order. Is that possible?

I know how to call the child pages individually using their page id. But if I did that, the parent page wouldn't automatically call in new content if a new child page was added.

Any pointers you can provide would be of great help. Thank you!

Right now I have this, which works for the post_title, but I'm just not figuring out how to implement it for the ACF repeater content:

<?php $childArgs = array( 'sort_order' => 'ASC', 'sort_column' => 'menu_order', 'child_of' => get_the_ID() ); $childList = get_pages($childArgs); foreach ($childList as $child) { ?> <div class="child-page"> <h2 class="child-title"><?php echo $child->post_title; ?></h2> <?php if( have_rows('a-gallery') ): ?>

        <div class="grand-works">

        <?php while( have_rows('a-gallery') ): the_row(); 

        // vars
        $image = get_sub_field('a-image');
        $thumbssize = get_sub_field('a-size-thumbs'); 


            <?php if( $image ): ?>

                    <img src="<?php echo $image ?>" class="thumbs-work grow <?php echo $thumbssize ?>">

            <?php endif; ?>

        <?php endwhile; ?>


    <?php endif; ?>
            <?php echo apply_filters( 'the_content', $child->post_content); ?>
    <?php } ?>

Is this questions related to your "How to display custom posts of only one category?" question?