1

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.

http://codex.wordpress.org/Function_Reference/get_page_children

$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.

Thanks!

1 Answer 1

3

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.

1
  • 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. Sep 14, 2010 at 21:03

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.