[wp-hackers] Unexpected behaviour in WP_Query
mwalters8 at gmail.com
Wed Feb 4 18:35:55 GMT 2009
I asked about it in #wordpress-dev about a month ago and was told
$post->post_category was fine to use for updating a posts categories,
but it does not retrieve the categories when the object is loaded.
So, not sure it really helps with the issue at hand, but just wanted
to point out it's not a complete fossil yet either.
On Wed, Feb 4, 2009 at 1:19 PM, scribu <scribu at gmail.com> wrote:
> I think $post->post_category is a fossil from older versions and doesn't
> serve any purpose.
> On Wed, Feb 4, 2009 at 8:13 PM, Sudar Muthu <sudar at sudarmuthu.com> wrote:
>> Hello all,
>> I was playing with WP_Query and found an unexpected behaviour. I am not
>> whether this is the expected behaviour or it is a bug. And if it is a bug,
>> will open a new ticket in trac.
>> This is the code which I am using in one of my Plugins to retrieve the
>> 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'));
>> 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
>> 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,
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers