Make WordPress Core

Opened 11 years ago

Last modified 17 months ago

#10230 assigned defect (bug)

get_pages function: number and child_of parameters conflict

Reported by: ortsaipekim Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.8
Component: Posts, Post Types Keywords: has-patch needs-testing needs-refresh
Focuses: template Cc:

Description (last modified by SergeyBiryukov)

Passing both number and child_of parameters to get_pages will produce nonsensical results.

Within the function number is used first to limit the number of results, then child_of is used to establish results within a certain hierarchical scope.

So with a structure of:

Parent 1 
Parent 2
Parent 3
   Child 1
   Child 2 
   Child 3

passing a number=2 and child_of=(parent 3 id) will not give the expected output. In this case, the result will first be limited to only include:

Parent 1 
Parent 2

so the child_of will be ignored. To produce a more logical result, child_of should be evaluated first, then number should be evaluated to limit the result set.

Attachments (1)

patch.post.php (1.4 KB) - added by arakeis 11 years ago.

Download all attachments as: .zip

Change History (14)

#1 @ortsaipekim
11 years ago

I meant to demonstrate the heirarchy as the following:

Parent 1
Parent 2
Parent 3

Child 1
Child 2
Child 3

#2 @Denis-de-Bernardy
11 years ago

  • Component changed from General to Query
  • Milestone changed from 2.8.1 to 2.9
  • Owner set to ryan

11 years ago

#3 @arakeis
11 years ago

  • Keywords has-patch added

#4 @arakeis
11 years ago

the proposed patch passes the number argument to the get_children function and prevents get_pages from limit(ing) the result from the query.
works fine on one of my client's site.

#5 @arakeis
11 years ago

  • Cc arakeis added

#6 @ryan
11 years ago

  • Milestone changed from 2.9 to 3.0

#7 @JoshSalverda
11 years ago

A quick fix for this is to pass in the "parent={parent_id}" along with all your other arguments. Obviously not a fix for the bug but if you need this sort of functionality then it will work for now.

#8 @dd32
11 years ago

  • Keywords needs-testing added; get_pages wp_list_pages removed
  • Milestone changed from 3.0 to Future Release

Bumping to Future release due to limited traction.

This also needs testing to ensure it doesn't break on complex queries involving children and offset/number

#9 @SergeyBiryukov
8 years ago

  • Component changed from Query to Template

Closed #10745 as a duplicate.

#10 @SergeyBiryukov
8 years ago

  • Description modified (diff)

#11 @nacin
7 years ago

  • Component changed from Template to Posts, Post Types
  • Focuses template added

#12 @ryan
6 years ago

  • Owner ryan deleted
  • Status changed from new to assigned

#13 @wonderboymusic
5 years ago

  • Keywords needs-refresh added
Note: See TracTickets for help on using tickets.