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 two levels of pages inside of it. the parent level we'll call parent, and child - child.

The parents need to be able to pull in their children, and the children need to be able to pull in their siblings (children of the same parent.)

If i were doing this in a normal page:

<?php $children = get_pages('child_of='.$post->ID);?>
if( count( $children ) != 0 ) { ?>
<section class="children">
Give us your Children
<?php }
else { ?>
<section class="siblings">
Give us your siblings
<?php } ?>

Of course - this doesn't work since get_pages only works with non-cpt "pages". I'm at a loss for the proper method inside a CPT - help much appreciated.

share|improve this question

get_pages() works with other post types just fine, you only need to pass post_type you want as part of argument (also I recommend to stick with array notation).

$children = get_pages( array( 'child_of' => $post->ID, 'post_type' => 'your_post_type', ) );
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.