#14823 closed defect (bug) (duplicate)
Allow get_pages to work with non-hierarchical post types
| Reported by: |
|
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)
Change History (7)
#2
@
15 years ago
- Milestone 3.1 deleted
- Resolution set to duplicate
- Status changed from new to closed
#3
@
15 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.
Tempted to close this as duplicate of #12821