WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 6 months ago

#12821 assigned enhancement

Merge get_posts() and get_pages() — at Version 15

Reported by: mikeschinkel Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.0
Component: Posts, Post Types Keywords: needs-testing needs-patch needs-unit-tests 3.8-early
Focuses: Cc:

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)

comment:1 nacin4 years ago

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

comment:2 scribu4 years ago

Me thinks get_posts() should handle both. get_pages() should be a wrapper for get_posts().

comment:3 scribu4 years ago

...similar to how get_categories() is a wrapper for get_terms().

comment:4 filosofo4 years ago

+1 to scribu's suggestion

comment:6 follow-up: scribu4 years ago

  • Keywords needs-patch added
  • Milestone changed from Unassigned to 3.1

comment:7 in reply to: ↑ 6 mikeschinkel4 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.

comment:8 scribu4 years ago

Go for it. You can set it's status to "accepted".

Just remember that it probably won't make it into WP 3.0.

comment:9 nacin4 years ago

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 mikeschinkel4 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 scribu4 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 scribu4 years ago

Related: #12873

comment:13 kevinB4 years ago

  • Cc kevinB added

comment:14 scribu4 years ago

  • Milestone Awaiting Triage deleted
  • Resolution set to wontfix
  • Status changed from new to closed

comment:15 nacin4 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()
Note: See TracTickets for help on using tickets.