Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

share|improve this question

1 Answer 1

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

 
discard

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.