[wp-hackers] get_posts bug, or feature?

andrew rader andrew.r.rader at gmail.com
Sun Dec 2 18:55:52 GMT 2007


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:

 category
    (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

thanks,
Andy


More information about the wp-hackers mailing list