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.



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.

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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