[wp-trac] [WordPress Trac] #14477: get_pages with child_of only works with uninterrupted hierarchies
WordPress Trac
noreply at wordpress.org
Tue Dec 2 03:00:19 UTC 2014
#14477: get_pages with child_of only works with uninterrupted hierarchies
-----------------------------------+-----------------------------
Reporter: vividvisions | Owner: wonderboymusic
Type: enhancement | Status: reopened
Priority: high | Milestone: 4.1
Component: Query | Version: 3.0
Severity: normal | Resolution:
Keywords: has-patch 2nd-opinion | Focuses:
-----------------------------------+-----------------------------
Changes (by dd32):
* status: closed => reopened
* resolution: fixed =>
Comment:
[attachment:14477-41-broken-ut.2.diff 14477-41-broken-ut.2.diff] shows
yet-another change in behaviour, which has a knock-on effect.
`get_page_children()` is now returning in alphabetical order, rather than
hierarchical order.
When used in conjunction with `wp_list_pages()` and `child_of > 0`, and a
sub-page with a `page_title` which is ordered before the `child_of`, it
causes `wp_list_pages()` to not be able to list the page hierarchy
correctly.
IMHO, this actually shows a bug in the `Walker_Page`. The `Walker_Page`,
well, really `Walker::walk` calculates `$top_level_elements` as being
`post_parent = 0`, and if none are found, then `post_parent = first
post_parent found`, this only works because it relies upon `get_pages()`
(which relies on `get_page_children()`) to return in a hierarchical order.
`get_pages()` by default returns posts in Alphabetical order, the catch is
that this is respected amongst the hierarchy, so `BB => AAA` should be
returned as `BB, AAA`, not `AAA, BB`.
The patch contains more explanation and examples..
--
Ticket URL: <https://core.trac.wordpress.org/ticket/14477#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list