Make WordPress Core

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's profile Kafkaesqui Owned by: ryan's profile 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)

5373.diff (400 bytes) - added by ryan 17 years ago.
5373-post-php-2.3.1.diff (405 bytes) - added by JDTrower 17 years ago.
Takes the solution in Ryan's patch and applies it to 2.3.1.
5373-post-php-2.3.2-beta.diff (405 bytes) - added by JDTrower 17 years ago.
Takes the solution in Ryan's patch and applies it to 2.3.2beta.
post-php.diff (266 bytes) - added by wlindley 17 years ago.
So hierarchical defaults to 1 if include= not specified, and 0 if include is. Permit both options together.

Download all attachments as: .zip

Change History (14)

@ryan
17 years ago

#2 @JDTrower
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.

@JDTrower
17 years ago

Takes the solution in Ryan's patch and applies it to 2.3.1.

@JDTrower
17 years ago

Takes the solution in Ryan's patch and applies it to 2.3.2beta.

#3 @JDTrower
17 years ago

  • Keywords has-patch added

#4 @ryan
17 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [6491]) Don't do hierarchical if includes specified. Props Kafkaesqui. fixes #5373 for 2.4

#5 @ryan
17 years ago

(In [6492]) Don't do hierarchical if includes specified. Props Kafkaesqui. fixes #5373 for 2.3

#6 @wlindley
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

@wlindley
17 years ago

So hierarchical defaults to 1 if include= not specified, and 0 if include is. Permit both options together.

#7 @ryan
17 years ago

  • Owner changed from anonymous to ryan
  • Status changed from reopened to new

#8 @lloydbudd
17 years ago

  • Milestone changed from 2.3.2 to 2.4

#9 @Denis-de-Bernardy
16 years ago

  • Component changed from General to Template

#10 @Denis-de-Bernardy
15 years ago

  • Milestone changed from 2.9 to 2.5
  • Resolution set to fixed
  • Status changed from new to closed

please re-open a separate ticket with feedback if your issue hasn't been fixed since.

Note: See TracTickets for help on using tickets.