[wp-trac] [WordPress Trac] #13412: Parent parameter returns no results in get_pages()
WordPress Trac
noreply at wordpress.org
Fri Dec 6 18:35:28 UTC 2013
#13412: Parent parameter returns no results in get_pages()
-------------------------+-----------------------------
Reporter: jda10487 | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: General | Version:
Severity: normal | Resolution:
Keywords: |
-------------------------+-----------------------------
Description changed by nofearinc:
Old description:
> 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.
New description:
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#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list