get_posts Should Use WP_Query
|Reported by:||filosofo||Owned by:|
|Component:||General||Keywords:||wp_query get_posts wpdb has-patch|
get_posts currently runs its own db queries based on the parameters it receives. Instead, it should query posts using WP_Query. Advantages:
- It avoids redundancy. query_posts and get_posts will have similar behavior, and a change in one place won't have to be doubled in the other.
- It adds functionality to both means of querying posts: all parameters passed to get_posts can be passed to query_posts, and vice-versa.
- It fixes some of get_posts problems, such as those for meta_key and meta_value, which currently are broken.
- It allows get_posts queries and results to be filtered.
To address the concern that this might be making significant changes to behavior, I've made a page template that lets you try queries in both the old get_posts and my proposed get_posts, simultaneously, with the results shown side-by-side. Just assign the attached template to a page, apply the patch, and you can see how my proposed get_posts query will work.
Change History (23)
- Resolution fixed deleted
- Severity changed from normal to blocker
- Status changed from closed to reopened