Parent parameter returns no results in get_pages()
|Reported by:||jda10487||Owned by:|
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):
$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.