WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom post type, with children 2 rows deep...

Outfit 1


Child 1 Child 1 Child 1 Child 1

Outfit 2


Child 1 Child 1 Child 1 Child 1

On the inner page, i need to show the content of the children, title, custom post types the normal stuff..

I have the following which does show the child content, but also that of the Outfit 1 and Inner..

<?php $loop = new WP_Query( array( 'post_type' => 'outfit','posts_per_page' => '-1','post_child' => 0 ) ); ?>

<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

         <?php the_title(); ?>
          <?php the_content(); ?>

<?php endwhile; ?>


Any idea how to limit it to just the children below Inner?

This is code that obviously appears on single-outfit.php also...

Thanks for any help :)

share|improve this question
up vote 0 down vote accepted

If I understand your question correctly, you try to just get the children and ignore the parent. Dont know where

post_child => 0

comes from but I'd use

post_parent => $parent_id

instead. In that case you have to catch the parent ID before you do any new queries. If you do something like this at the beginning of your template:

$this_page_id = $post->ID;

you can refer later, in your new Query, to that id and just query child pages by using

post_parent => $this_page_id
share|improve this answer

Your Answer


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.