Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#14823 closed defect (bug) (duplicate)

Allow get_pages to work with non-hierarchical post types

Reported by: aaroncampbell's profile aaroncampbell Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: dev-feedback has-patch
Focuses: Cc:

Description

I discovered this issue while working on making a custom post type a child of another custom post type. I know that's an edge case, but stay with me. I needed something like page_attributes_meta_box() but I needed to show the parent post type in the dropdown, so I rolled my own (there are no filters available for this).

My new function needed to use wp_dropdown_pages() but kept getting an empty set. It turns out it's because wp_dropdown_pages() uses get_pages(), which does a seemingly unnecessary check to make sure the post type is hierarchical. I made it work by making my post type hierarchical, but that messes up the URLs.

Attachments (1)

14823.001.diff (747 bytes) - added by aaroncampbell 14 years ago.

Download all attachments as: .zip

Change History (7)

#1 @scribu
14 years ago

Tempted to close this as duplicate of #12821

#2 @nacin
14 years ago

  • Milestone 3.1 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

#3 @grandslambert
14 years ago

  • Cc shane@… added
  • Resolution duplicate deleted
  • Status changed from closed to reopened

Can someone explain to me why wp_dropdown_pages still does not allow non-hierarchical post types? With Custom Post Types able to be set to page compatibility and non-hierarchical, this should be a non issue. I understand why in the past page types were hierarchical and post types were not. However, things have changed and there are use cases where non-hierarchical post types with the page compatibility are going to be used, and we as plugin developers are going to need to get a dropdown of page types that are non-hierarchical.

Or perhaps a new function, wp_dropdown_posts(), should be considered. For now I guess I will have to create my own because I just have to have something that works.

#4 @scribu
14 years ago

  • Resolution set to duplicate
  • Status changed from reopened to closed

First of all, this ticket was marked as duplicate. Therefore, any question you have should be directed to the main ticket, #12821.

If you were to read #12821, you would see that it would take care of your problem.

#5 @grandslambert
14 years ago

Sorry, but I do not feel they are the same issue. I will however post future follow ups on that ticket that seems to be going nowhere to fix this problem.

#6 @scribu
14 years ago

If get_pages() is merged into get_posts(), then when wp_dropdown_pages() calls get_pages(), it will work for non-hierarchical post types too. Problem solved.

Note: See TracTickets for help on using tickets.