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 :)


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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