I have several pages all under one parent like this

ParentPage (ID 24)

  • ChildPage A
  • ChildPage B
  • ChildPage C
  • ChildPage D
  • ChildPage E
  • ChildPage F

I am using WP_Query to return all the child pages but only some are coming back. In the DB all the child pages have the same parent ID of 24.

// args
$args = array(
    'numberposts'   => -1,
    'post_type'     => 'page',
    'post_parent' => 24

// query
$the_query = new WP_Query( $args );

// loop through posts
if( $the_query->have_posts() ): ?>
    <?php while( $the_query->have_posts() ) : $the_query->the_post();?>
        <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    <?php endwhile; ?>
<?php endif; ?>

Let's say B & C don't return. I tried assigning it to a new parent (ID25) and modify the query to return child pages of parent 25 - and the missing pages display fine.

I have virtually no plugins other than ACF PRO, which -- prior to making some new pages and fields for said pages recently -- was working fine.

1 Answer 1


Red faced - but happy to share the results and save someone else the pain. I have been chasing a ghost for the last two days, there is a default number of posts the wp_query returns which is page specific. It seems to be set to 10 posts on the page I am on.

All you have to do is specify the number of posts you want to override the default values. In my case I wanted them all so I added the following to the query args.

'posts_per_page' => -1

I really hope this helps someone, dark couple of days and I was starting to incorrectly point fingers at plugins that were behaving just fine.

Found this out at wp query to get child pages of current page

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.