[wp-hackers] Unexpected behaviour in WP_Query
Sudar Muthu
sudar at sudarmuthu.com
Wed Feb 4 18:13:19 GMT 2009
Hello all,
I was playing with WP_Query and found an unexpected behaviour. I am not sure
whether this is the expected behaviour or it is a bug. And if it is a bug, I
will open a new ticket in trac.
This is the code which I am using in one of my Plugins to retrieve the posts
belonging to a particular category. Both code and output available in
pastebin as well at http://pastebin.com/m46539116
$my_query = new WP_Query;
$posts = $my_query->query(array('category__in'=>array($cat_id),
'post_type'=>'post', 'nopaging'=>'true'));
print_r($posts);
And in the output I have the following line
[post_category] => 0
So the function is retrieving the posts, but in the result, the category is
0. I tried to trace the SQL generated in this case and it is available in
pastebin at http://pastebin.com/m7a889bdc
The category is 0 even when I execute the generated SQL directly in my
database.
I strongly feel that it is a bug. So please let me know whether it is a bug
or it an expected behaviour. Thanks!
With Regards,
Sudar
http://SudarMuthu.com
http://twitter.com/sudarmuthu
More information about the wp-hackers
mailing list