Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#39369 closed defect (bug) (fixed)

The document of wp_list_pages() is not clear.

Reported by: doublehhh's profile doublehhh Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.8 Priority: normal
Severity: normal Version: 4.8
Component: Posts, Post Types Keywords: has-patch
Focuses: docs Cc:

Description

The document of wp_list_pages() is not clear. Developers can use non-hierarchical post type. It makes them confused.

Attachments (1)

39369.patch (473 bytes) - added by doublehhh 8 years ago.

Download all attachments as: .zip

Change History (6)

@doublehhh
8 years ago

#1 @Kenshino
8 years ago

  • Keywords has-patch added
  • Type changed from enhancement to defect (bug)

#2 follow-up: @swissspidy
8 years ago

wp_list_pages() does not support setting the post type in $args. The function uses get_pages() which in turn supports that, but not when called via wp_list_pages().

For 39369.patch to be true, wp_list_pages() would actually need to support this.

#3 in reply to: ↑ 2 @SergeyBiryukov
8 years ago

  • Milestone changed from Awaiting Review to 4.8

Replying to swissspidy:

wp_list_pages() does not support setting the post type in $args.

I think it does, as it passes the list of arguments directly to get_pages(), and post_type is one of the documented arguments in both functions.

I've just tested wp_list_pages() with a hierarchical CPT, and it works as expected.

#4 @swissspidy
8 years ago

post_type is one of the documented arguments​ in both functions.

Welp, my bad. I seem to have only looked at $defaults and missed it in the docblock of wp_list_pages().

#5 @SergeyBiryukov
8 years ago

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

In 40027:

Docs: Clarify that wp_list_pages() and get_pages() only work with hierarchical post types.

Props doublehhh.
Fixes #39369.

Note: See TracTickets for help on using tickets.