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 registered a custom post type (foo) with register_post_type, setting 'hierarchical' => true,so now when I want to use it I have post_type=foo.

How can I query child of foo? any ideas?

thanks!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You can display child pages of particular parent foo page using following code ( using parent page ID ):

$the_query = new WP_Query( 'post_type=foo&post_parent=93' );

// The Loop
while ( $the_query->have_posts() ) :
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
endwhile;
share|improve this answer
    
thanks mate, I was looking for all complex solutions but nothing so obvious, thanks a lot! –  bboy Feb 28 '13 at 10:57

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.