Opened 3 years ago
Last modified 11 months ago
#12821 assigned enhancement
Merge get_posts() and get_pages() — at Version 15
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | Post Types | Version: | 3.0 |
| Severity: | normal | Keywords: | has-patch needs-testing |
| Cc: | kevinB, mikeschinkel@…, aaroncampbell, steph@…, WordPress@…, info@…, shane@…, frederic.demarle@…, andrewsfreeman |
Description (last modified by nacin)
get_pages() should wrap get_posts() the same way get_page() wraps get_post(). Arguments of different names need to be retained for back compat.
Reasoning for this includes #14823. Querying a nonhierarchical post type should still be allowed with child_of for example, to allow for cross-type relationships.
Change History (15)
Me thinks get_posts() should handle both. get_pages() should be a wrapper for get_posts().
comment:5
mikeschinkel — 3 years ago
+1
- Keywords needs-patch added
- Milestone changed from Unassigned to 3.1
comment:7
in reply to:
↑ 6
mikeschinkel — 3 years ago
Replying to scribu:
I'd like to try to create this patch. I think the scope it defined small enough and straightforward enough that I could tackle it. This would give me the first patch beyond trivial for me to contribute.
If you think it's okay for me to take it on please assign to me.
Go for it. You can set it's status to "accepted".
Just remember that it probably won't make it into WP 3.0.
Go for it. In general, just find a ticket and write a patch if you'd like. I never found a need to mess with the owner components for the most part, though I find it helpful as a committer now.
We need to be fully back compat. The args order and sort_order (and orderby and sort_column) must both stay, for example. We'd want to make orderby and order the 'proper' ones since that is our naming convention. The structural differences between the two -- get_pages() relies on its own query, while get_posts() uses WP_Query, for example -- should be interesting to merge.
Just remember that it probably won't make it into WP 3.0.
Yeah, this isn't going to happen for 3.0. Way too much to change and test late in the dev cycle. Consider it blessed for 3.1 as of ryan's comment in #4711.
comment:10
mikeschinkel — 3 years ago
@scribu / @nacin
Thanks. Agree with full backward compatibility.
So for clarity we want to start using the parameters that get_posts() uses in addition to the ones get_pages() has always used so that get_pages() can behave like get_posts() but also so it can still behave the same as it used to.
As far as the two queries, do you know if there's any current incompatibilities between the two?
Understood about 3.1 vs. 3.0 and agree. 3.0 is ready to close out, not add new things to it.
Last question: Shouldn't I create a new ticket for the merge and close this one out?
comment:11
scribu — 3 years ago
So for clarity we want to start using the parameters that get_posts() uses in addition to the ones get_pages() has always used so that get_pages() can behave like get_posts() but also so it can still behave the same as it used to.
The other way around: add the get_pages() specific parameters ('child_of', 'exclude_tree' etc.) to get_posts(). Then, retrofit get_pages() to use get_posts().
Last question: Shouldn't I create a new ticket for the merge and close this one out?
Sure, just mention this one in the description.
comment:12
scribu — 3 years ago
Related: #12873
comment:13
kevinB — 3 years ago
- Cc kevinB added
comment:14
scribu — 3 years ago
- Milestone Awaiting Triage deleted
- Resolution set to wontfix
- Status changed from new to closed
comment:15
nacin — 3 years ago
- Description modified (diff)
- Milestone set to 3.1
- Resolution wontfix deleted
- Status changed from closed to reopened
- Summary changed from Allow get_pages() to query non-heirarchical post types? to Merge get_posts() and get_pages()

get_pages() should be hierarchical. get_posts() should be non-hierarchical.