Make WordPress Core

Opened 5 years ago

Closed 8 months ago

#9470 closed enhancement (fixed)

Allow get_pages to get child pages of multiple pages

Reported by: joostdevalk Owned by:
Milestone: 3.7 Priority: normal
Severity: normal Version: 2.8
Component: Query Keywords: has-patch commit
Focuses: Cc:


I'm doig a lot of WordPress CMS work, and am finding it increasingly annoying that i can only get the children of one page through get_pages.

It would be great if child_of could also, just like include and exclude, be a comma separated array of pages for which you want to fetch the children.

Attachments (2)

9470.diff (680 bytes) - added by wonderboymusic 8 months ago.
9470.2.diff (2.7 KB) - added by wonderboymusic 8 months ago.

Download all attachments as: .zip

Change History (10)

comment:1 nbachiyski5 years ago

  • Keywords needs-patch added

comment:2 Denis-de-Bernardy5 years ago

  • Milestone changed from Unassigned to Future Release
  • Version set to 2.8

have you tried there is a page walker class?

comment:3 Denis-de-Bernardy5 years ago

  • Component changed from General to Query

comment:5 Japh18 months ago

  • Cc japh@… added

wonderboymusic8 months ago

comment:6 wonderboymusic8 months ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Future Release to 3.7

9470.diff Allows parent to accept an array:

$p = get_pages();
$p = get_pages( array( 'parent' => 0 ) );
$p = get_pages( array( 'parent' => 7 ) );
$p = get_pages( array( 'parent' => array( 3, 5, 7, 9 ) ) );

wonderboymusic8 months ago

comment:7 wonderboymusic8 months ago

  • Keywords commit added

.2.diff adds unit tests and fixes a nasty bug that deletes your results after it finds them if you only pass the parent arg

comment:8 wonderboymusic8 months ago

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

In 25244:

Allow get_pages() to accept an array for the arg parent. Adds unit tests, some will fail until the next commit.

Fixes #9470.

Note: See TracTickets for help on using tickets.