[wp-trac] [WordPress Trac] #13412: Parent parameter returns no results in get_pages()

WordPress Trac wp-trac at lists.automattic.com
Sun May 16 16:53:40 UTC 2010


#13412: Parent parameter returns no results in get_pages()
--------------------------+-------------------------------------------------
 Reporter:  jda10487      |       Owner:            
     Type:  defect (bug)  |      Status:  new       
 Priority:  normal        |   Milestone:  Unassigned
Component:  General       |     Version:            
 Severity:  normal        |    Keywords:            
--------------------------+-------------------------------------------------
 The get_pages() function in post.php returns no results when parent != 0,
 rather than returning the pages that are children of the immediate page.

 Given page ID 30, which has 3 child pages, calling get_pages('parent=30')
 will return nothing.

 The problem is in the following lines (line ~2600 at the time of writing):
 if ( $child_of || $hierarchical )
         $pages = & get_page_children($child_of, $pages);

 Hierarchical, by default, is set to true, this this conditional will
 typically be true. When it does so, it filters out all of the pages
 retrieved up to this point and, by the time it returns, there are no pages
 left.

 The quick work-around I'm currently using is to call the following
 instead:
 get_pages('parent=0&hierarchical=0'), overriding the default value so that
 conditional doesn't execute.

 The one exception to this is that calling get_pages('parent=0') should
 function even with this bug.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/13412>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list