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 use the get_page_children() function to create a sub_nav for a designer client I do work for. She uses the Spry Assets flyout JS that DreamWeaver creates, so I have to manually do the menus like this rather than use the new menus functionality in WordPress.

I had them all set up and working perfectly, and then my client upgraded to 3.0.1 and somehow she says that broke them. I'm not sure if it happened then or if it was something else that caused the break.

I've narrowed down the problem. The Codex says you need to get a list of all page objects to use for this function. You use a "query" function I've never seen before.


$my_wp_query = new WP_Query();
$all_wp_pages = $my_wp_query->query(array('post_type' => 'page'));

Those 2 lines should generate an array of all of your page objects that is usable by get_page_children() later.

However, it's not working anymore because $all_wp_pages ISN'T all of my pages. I have 38 pages on this site, and when I do an output of the $all_wp_pages array, I only get 10 pages.

Anyone have any idea why that would be happening? The 10 pages that do show up all happen to be ONE page and its children. But they show up no matter what page you're on. It's really bizarre.


share|improve this question
up vote 3 down vote accepted

I don't have enough pages to test, but I have an idea that 10 is default pagination number.

$all_wp_pages = $my_wp_query->query(array(
    'post_type' => 'page',
    'posts_per_page' => -1

If this doesn't work I will try to find some time to generate bunch of pages and test.

share|improve this answer
That was it. Damn. So easy. Thanks, man! (I'm confused why this was working before and just stopped working when we upgraded to 3.0.1, though...) Thanks again. – Jason Rhodes Sep 14 '10 at 21:03
AMAZING!!! Thank you! – Alex Thomas Mar 2 '12 at 16:13

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.