Support » Fixing WordPress » Child pages on parent page problem

  • Hi all,

    So basically I need to display child page excerpt, thumbnail and title by category on the parent page. I have everything working, however, it shows all pages in category and not just those pages that are sub or child pages to the parent page. This code would be in a page template and so would work for multiple pages.

    Please offer any advice you can think off and I will try it, I have been racking my brain!

    Thanks again, the code is below:

    <?php if ( have_posts() ) {  /* Query and display the parent. */
    	while ( have_posts() ) {
    	the_post();
    	$thispage=$post->ID;
    	}
    } ?>
    <php? /* Back up global $post object. */
    $post_backup = $post; ?><div style="width: 100% !important; float:left;">
    <div class="comparison-stories"><div id="comparison-container_division">
    <?php $childpages = query_posts('post_per_page=5&orderby=menu_order&order=asc&post_type=page&post_parent=.$thispage&cat=16');
    	if($childpages){ /* display the children content  */
    	       	foreach ($childpages as $post) :
    	        setup_postdata($post); ?>
     <div class="comparison-post-block"><div class="wrapper"><div class="top-5-image">
    <?php the_post_thumbnail('medium'); ?></div></div>
    <div class="comparison-top5-text">
    	        <div class="wrapper"><div class="top-5-title"><p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p> </div></div>
    		<div class="wrapper"><div class="comparison-content"><div class="comparisonexcerpttext"><?php the_excerpt(); ?></div></div></div></div></div>
    
    	 <?php
    	  endforeach;
    	 } ?>
    <php? /* Restore global $post object. */ $post = $post_backup; ?>
    </div></div></div>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Child pages on parent page problem’ is closed to new replies.