Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using a custom field query (or trying to) :

$args =  array(
    'post_type'     => 'pf_cookbook', 
    'meta_query'    => array(
        'key'           => 'pf_cookbook_recipes',
        'value'         => '5',
        'compare'       => 'NOT IN',
        'type'          => 'NUMERIC'
    ) 
);

However, the meta value to be compared is an array. The idea here is I am querying the DB to get the cookbooks which don't contain a certain recipe. The Recipes & Cookbooks are Custom Post Types. The Cookbooks have a meta key 'pf_cookbook_recipes' which I am storing an array of recipe IDs.

Maybe I am missing something?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

meta_query needs to be an array of arrays - have a look at the code sample in the Codex again.

So, for your example:

$args =  array(
   'post_type'   => 'pf_cookbook', 
   'meta_query'  => array(
                       array(
                        'key'           => 'pf_cookbook_recipes',
                        'value'         => '5',
                        'compare'       => 'NOT IN',
                        'type'          => 'NUMERIC'
                        )
                    )
); 

);

share|improve this answer
    
Thanks, my brain has gone to mush after 4 days off. Thanks, i'll mark as answered when I can. –  Cristian Apr 26 '11 at 10:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.