WordPress.org

Ready to get started?Download WordPress

Forums

Echo child pages of parent page in respective template (1 post)

  1. CHEWX
    Member
    Posted 7 months ago #

    Hi,

    So I have a page called meet the team, and then child pages with each staff member.

    I can echo the child pages within the homepage fine.

    Each child page has it's own template, I want to echo each respective template within the loop.

    <?php
       $pages = get_pages('child_of=29&sort_column=menu_order&sort_order=asc');
       $i = 0;
       foreach($pages as $page) {?>
          Each template for child page goes here
    <?php $i++; } ?>

    Example of child page template

    <?php /*Template Name: Team Long Photo Bottom*/ ?>
    <article class="longTop">
        <div class="photo">
            <?php echo get_the_post_thumbnail($page->ID, ''); ?>
        </div>
        <div class="text">
            <h2 class="name"><?php the_title();?></h2>
            <div class="title"><?php echo get_post_meta($post->ID, 'title', true); ?></div>
            <p class="content"><?php the_content(); ?></p>
        </div>
    </article>

Reply

You must log in to post.

About this Topic