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.

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

Outfit 1

Inner

Child 1 Child 1 Child 1 Child 1

Outfit 2

Inner

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..

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

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

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

<?php endwhile; ?>

  </ul>

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
add comment

1 Answer

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
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.