#14823 closed defect (bug) (duplicate)
Allow get_pages to work with non-hierarchical post types
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Post Types | Version: | |
| Severity: | normal | Keywords: | dev-feedback has-patch |
| Cc: | shane@… |
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)
aaroncampbell — 3 years ago
- Milestone 3.1 deleted
- Resolution set to duplicate
- Status changed from new to closed
comment:3
grandslambert — 2 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.
- Resolution set to duplicate
- Status changed from reopened to closed
comment:5
grandslambert — 2 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.

Tempted to close this as duplicate of #12821