Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 6 months ago

#24384 closed defect (bug) (invalid)

get_pages('parent=1') returns nothing

Reported by: tomdxw's profile tomdxw Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5.1
Component: General Keywords:
Focuses: Cc:

Description

get_pages('parent=1') returns an empty array
get_pages('parent=1&hierarchical=0') returns an array of pages
get_pages('parent=0') returns an array of pages

(assuming there is a page with ID=1 and it has children)

It seems like if parent=0 works then parent=1 should also work.

Change History (2)

#1 @MattyRob
12 years ago

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

Documentation for that functions is here:
http://codex.wordpress.org/Function_Reference/get_pages

It indicates there are two valid options for the argument 'parent', namely -1 (to return all pages) and 0 (to return top level pages only).

I suspect the function you need is get_children() that will return a passed page ID and all of it's children.

#2 @SergeyBiryukov
12 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.