[wp-hackers] get_posts bug, or feature?
otto at ottodestruct.com
Tue Dec 4 21:44:14 GMT 2007
The get_posts function in post.php doesn't look like it will do what
you say it's doing. It doesn't merge children into the category part
of the query. It's adding this to the where clause
AND (wp_posts.ID = wp_term_relationships.object_id AND
wp_term_taxonomy.term_taxonomy_id AND $wpdb->term_taxonomy.term_id =
That's not going to get children categories too.
Are you use that you're not using $wp_query->get_posts() instead?
Because that behaves differently.
On 12/2/07, andrew rader <andrew.r.rader at gmail.com> wrote:
> Hi all,
> I'm revisiting a plugin I've written using WP 2.3.1, and I'm seeing
> undesired behavior in get_posts.
> my plugin, fancy-categories, displays the posts in a given category
> directly in the sidebar list. I use
> get_posts("numberposts=0&category=$catID") to get the posts of a given
> category. The problem is that this code returns not only posts in the
> $catID category, but also posts in the categories that are SUB
> categories to $catID.
> the documentation here:
> http://codex.wordpress.org/Template_Tags/get_posts says that:
> (integer) Only show posts from this category ID. There is no default.
> This makes me think that get_posts should only return those posts
> directly in that category. I also believe this is how it worked prior
> to 2.3 (but I have yet to verify)
> is this a bug? or a "feature". If it's intended behavior, I think the
> get_posts open should allow you to exclude posts in sub-categories
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers