[wp-hackers] Why in the heck won't this work?

Viper007Bond viper at viper007bond.com
Thu Aug 23 11:06:10 GMT 2007


Perhaps coding at 4am isn't the best idea, I know, but I can't figure out
for the life of me why this won't work.

I've made of copy of in_category() and modified it slightly to accept the
post ID rather than getting it from the global $post (due to use in a plugin
-- I need to find out if a certain post is in a certain category).

My code: http://wordpress.pastebin.com/f5c7e4b6a

The original's $categories array's keys are the values of the category ID.

ex:

Array
(
    [6] => stdClass Object
        (
            [term_id] => 6


However, the one in my function does it sequentially:

Array
(
    [0] => stdClass Object
        (
            [term_id] => 6


Then 1, then 2, etc.

Due to this, the array_key_exists() test is failing.

Any ideas why? I don't see what is making the difference.

-- 
Viper007Bond | http://www.viper007bond.com/


More information about the wp-hackers mailing list