Opened 17 years ago
Closed 15 years ago
#5373 closed defect (bug) (fixed)
wp_list_pages - set 'hierarchical' to 0 on 'include'
Reported by: | Kafkaesqui | Owned by: | ryan |
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | normal | Version: | 2.3.2 |
Component: | Template | Keywords: | wp_list_pages include hierarchical child has-patch |
Focuses: | Cc: |
Description
Using wp_list_pages() with the 'include' argument, the included Page(s) list will not appear if they have been assigned a parent.
I traced this down to the 'hierarchical'
parameter, which is set to 1 by default. It should added to the "ignore" list of variables in the if ( !empty($include) )
statement under the get_pages() function (wp-includes/post.php).
Attachments (4)
Change History (14)
#2
@
17 years ago
When I tried to apply the patch that Ryan added to 2.3.1 and 2.3.2beta, I got an error that the patch line and the file line did not match. I manually applied the patch myself and tested it based on the information in the supplied forum topic. The patch resolved the issue that was occurring in the forum topic. I am posting two new patches, one that works for 2.3.1 and one that works for for 2.3.2beta.
While I was testing the problem in the trunk, I was getting the intended effect without having the patch applied. So it appears, that we have already resolved this issue in 2.4-bleeding.
#6
@
17 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
- Version changed from 2.3.1 to 2.3.2
I have written a plugin that depends on hierarchical=1 along with include= ... specifically, I create a page-list that shows an indented "breadcrumb-style" list of pages from top-level down to your current location, along with all the current page's "brothers" and "uncles" etc. up to the main level.
The patch in v2.3.2 breaks this functionality, because my "&hierarchical=1" gets overridden, and the page structure collapses.
In other words, $hierarchical needs to default to 1 if &include= is not specified, and default to 0 if &include= is specified. But now, when explicitly specifying both, hierarchical gets discarded.
One way to solve this is change line 1146 to be:
if ($hierarchical == 1) $hierarchical = false;
and line 1126, make the default "2" (so an explicit "1" won't override):
'sort_column' => 'post_title', 'hierarchical' => 2,
Perhaps there's a more elegant way of making a "dependent default" but this makes all cases work.
--
/illiam
Real world ref:
http://wordpress.org/support/topic/144403#post-651718