I am trying to display the DIRECT children of another page on the homepage but I can't seem to get it working it just shows all of the page titles on the site..

It needs to be within a wp_query as I require to use advanced custom fields on the pages

My code:


            $the_query = new WP_Query( array( 'post_type' => 'page', 'parent' => 42, 'child_of' => 0,) );

                while ( $the_query->have_posts() ) : $the_query->the_post();

                    echo '<h3>'; the_title(); echo '</h3>';

                    echo '<p>' ; the_field('enter_stuff_here'); echo '</p>';



My understanding was if I used the ID of the parent that this would show all of the DIRECT children of this page (please note I don't want t o show grandchildren but ONLY DIRECT child pages)

Thanks in advance for the help!

  • 2
    I just realised it had to be 'post_parent' => 42 - i'm an idiot!
    – Kieran
    Commented May 7, 2014 at 21:03

1 Answer 1

 $the_query = new WP_Query( array( 'post_type' => 'page', 'parent' => 42, 'child_of' => 0,) );

You should edit this line like following:

$the_query = new WP_Query( array( 'post_type' => 'page', 'post_parent' => 42) );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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