Ticket #5373 (new defect)

Opened 10 months ago

Last modified 8 months ago

wp_list_pages - set 'hierarchical' to 0 on 'include'

Reported by: Kafkaesqui Assigned to: ryan
Priority: normal Milestone: 2.9
Component: General Version: 2.3.2
Severity: normal Keywords: wp_list_pages include hierarchical child has-patch
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

5373.diff (400 bytes) - added by ryan on 11/21/07 00:22:16.
5373-post-php-2.3.1.diff (405 bytes) - added by JDTrower on 12/21/07 23:44:36.
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 on 12/21/07 23:45:11.
Takes the solution in Ryan's patch and applies it to 2.3.2beta.
post-php.diff (266 bytes) - added by wlindley on 12/31/07 17:55:36.
So hierarchical defaults to 1 if include= not specified, and 0 if include is. Permit both options together.

Change History

11/20/07 22:06:43 changed by Kafkaesqui

11/21/07 00:22:16 changed by ryan

  • attachment 5373.diff added.

12/21/07 23:43:34 changed by JDTrower

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.

12/21/07 23:44:36 changed by JDTrower

  • attachment 5373-post-php-2.3.1.diff added.

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

12/21/07 23:45:11 changed by JDTrower

  • attachment 5373-post-php-2.3.2-beta.diff added.

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

12/21/07 23:48:21 changed by JDTrower

  • keywords changed from wp_list_pages include hierarchical child to wp_list_pages include hierarchical child has-patch.

12/24/07 21:24:03 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

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

12/24/07 21:24:26 changed by ryan

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

12/31/07 17:44:12 changed by wlindley

  • status changed from closed to reopened.
  • version changed from 2.3.1 to 2.3.2.
  • resolution deleted.

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

12/31/07 17:55:36 changed by wlindley

  • attachment post-php.diff added.

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

12/31/07 18:02:15 changed by ryan

  • owner changed from anonymous to ryan.
  • status changed from reopened to new.

01/02/08 19:48:33 changed by lloydbudd

  • milestone changed from 2.3.2 to 2.4.