Make WordPress Core

Opened 19 years ago

Closed 19 years ago

#1171 closed defect (bug) (fixed)

Page caching, wp_list_pages and child_of

Reported by: mdawaffe's profile mdawaffe Owned by: ryan's profile ryan
Milestone: Priority: normal
Severity: minor Version: 1.5.1
Component: General Keywords:
Focuses: Cc:

Description

Currently, using child_of in wp_list_pages only returns the direct children of the passed value rather than the entire subhierarchy below that page.

Example:
Page1
-Page2
-Page3
--Page4
-Page5

Calling wp_listpages(child_of=1) yields a listing of Pages 2, 3, and 5. NOT 4.

This can be remedied by using $cache_pages when possible in wp_list_pages() instead of calling get_pages().

Patch submitted.

Attachments (1)

wplistpage.diff (619 bytes) - added by mdawaffe 19 years ago.

Download all attachments as: .zip

Change History (8)

#1 @mdawaffe
19 years ago

  • Patch set to No

#2 @ryan
19 years ago

  • Owner changed from anonymous to rboren
  • Status changed from new to assigned

#4 @mdawaffe
19 years ago

Recursion is still broken.

I have the following (where the numbers are the Page ID):
New Page(3)
-testing(12)
-one(15)
--test(4)

wp_list_pages(sort_column=post_title&child_of=3);
displays:
one(15)
-test(4)

Instead of:
one(15)
-test(4)
testing(12)

and wp_list_pages(sort_column=ID&child_of=3);
displays:
testing(12)

Instead of:
testing(12)
one(15)
-test(4)

The problem is with the recursive referencing. Or at least changing the get_page_children function definition from:
function &get_page_children($page_id, &$pages)

to:
function &get_page_children($page_id, $pages)
(note lack of ampersand on $pages)

fixes things.

#6 @mdawaffe
19 years ago

Works for me.

#7 @ryan
19 years ago

  • fixed_in_version set to 1.5.1
  • Resolution changed from 10 to 20
  • Status changed from assigned to closed

@mdawaffe
19 years ago

Note: See TracTickets for help on using tickets.