Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How would I display a list of my child pages using featured images on a its parent page as well as its other siblings child page?

For example, if my parent page is called 'Music', I'll have my main content with child pages thumbnails at the bottom.

I'd like to have thumbnails with permalinks to other child pages from within the parent Music page displayed across all of the child music pages.

Is this possible?

Thanks

share|improve this question
    
There are a number of related questions to the right under "Related". Do none of those help? –  s_ha_dum Jun 11 '13 at 21:34
    
Some of these are useful, but i'm still in need to post the thumbnails with permalinks of child pages, when even on other child pages from the same parent page? –  David Jun 11 '13 at 21:41
add comment

2 Answers

Use get_ancestors to get the page parent, then get the children of that parent.

$ancestors = array();
$ancestors = get_ancestors($post->ID,'page');
$parent = (!empty($ancestors)) ? array_pop($ancestors) : $post->ID;
if (!empty($parent)) {
  $kids = new WP_Query(
    array(
      'post_parent'=>$parent,
      'post_type' => 'page',
      'ignore_sticky_posts' => true
    )
  );
  if ($kids->have_posts()) {
    while ($kids->have_posts()) {
      $kids->the_post();
      echo '<a href="'.get_permalink().'" title="'.get_the_title().'">'.get_the_post_thumbnail().'</a>';
    }
  }
}
share|improve this answer
    
how do I link the thumbnails to their permalink pages? –  David Jun 11 '13 at 22:28
    
@David : see the edit –  s_ha_dum Jun 11 '13 at 22:37
    
Thanks so much for this sir, it worked a charm! –  David Jun 11 '13 at 22:41
add comment

This is the best solution worked so far for me, which is combination of multiple solutions i found online,

With this code you can display Sub Page Featured Image and Title with anchor link.

Also this work for Sub and Child page too.

<!--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 '<article class="span_8 col clr-margin products-thumb"> <a href="'.get_permalink().'" title="'.get_the_title().'">'.get_the_post_thumbnail().'</a>'.'<br/><h2><a href="'.get_permalink().'">'.get_the_title().'</a></h2></article>';
  endwhile; 
endif; 
wp_reset_postdata(); ?>
<!--Child Page Thumbnails End-->
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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