0

I am currently working on a custom template for a page, and I would like to pull various information from the child pages of the parent page, and display that information on the parent page. Specifically, I would like to be able to pull the featured image, title, and the text (above the break line, if it's possible to specify), and display them on the parent page, cycling through each child page. There is plenty of information out there on how to display a list of child pages, but I am having trouble finding information on how to do this, specifically.

1
  • Can you show the code for your parent page loop? :)
    – Aravona
    Commented Mar 7, 2017 at 17:09

1 Answer 1

0

Something like this would work:

<!--Child Page Thumbnails Start-->
<?php 
  $subs = new WP_Query( 
    array( 
      'post_parent' => $post->ID, 
      'post_type' => 'page', 
      'meta_key' => '_thumbnail_id' 
    )
  );
if( $subs->have_posts() ) : 
  while( $subs->have_posts() ) : 
    $subs->the_post();
    echo '<a href="'.get_permalink().'" title="'.get_the_title().'">'.get_the_post_thumbnail().'</a>'.'<br/><h2><a href="'.get_permalink().'">'.get_the_title().'</a></h2>';
  the_content();    
  endwhile; 
endif; 
wp_reset_postdata(); ?>
<!--Child Page Thumbnails End-->

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.