[wp-trac] [WordPress Trac] #4070: rewrite get_posts to call
WP_Query->get_posts, using temporary filters as needed
WordPress Trac
wp-trac at lists.automattic.com
Mon Apr 2 20:04:24 GMT 2007
#4070: rewrite get_posts to call WP_Query->get_posts, using temporary filters as
needed
-------------------------+--------------------------------------------------
Reporter: kevinB | Owner: markjaquith
Type: enhancement | Status: new
Priority: normal | Milestone: 2.2
Component: General | Version:
Severity: normal | Keywords: get_posts
-------------------------+--------------------------------------------------
The get_posts function in post.php seems redundant and hinders plugin API
consistency. Plugin functions filtering WP_Query->get_posts should not
suffer the ignominy of unfiltered results sneaking out through a
redundant, unhookable equivalent function. Why not just make get_posts
wrap WP_Query->get_posts?
Attached patch rewrites get_posts to call WP_Query->get_posts. The
arguments numberposts and category are remapped to posts_per_page and cat.
get_posts arguments which WP_Query->get_posts does not (yet?) support are
include, exclude, meta_key, meta_value, post_parent. These are supported
by way of temporary filters on posts_join and posts_where.
If the future development path involves upgrading WP_Query->get_posts to
support these other args, get_posts can be simplified, ultimately to a 10-
line wrapper.
Since WP_Query->get_posts already supports multiple category
inclusion/exclusion, this solves #1625 too.
If this is not the direction y'all want to go, please say so and I will
submit another ticket with new hooks in post.php~get_posts. But the
wrapper approach seems cleaner to me. Why have two sets of hooks for the
same query?
For sample usage, see themes\tarski\footer.php
--
Ticket URL: <http://trac.wordpress.org/ticket/4070>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list