I'm having a lot of trouble since upgrade to 3.0.1 with get_page_children() function

wordpress.stackexchange https://wordpress.stackexchange.com/questions/1775

  •  16-10-2019
  •  | 
  •  

Question

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!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top