1

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?

    1 Answer 1

    4

    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' ) ) ); 

    );

    1
    • Thanks, my brain has gone to mush after 4 days off. Thanks, i'll mark as answered when I can.
      – Cristian
      CommentedApr 26, 2011 at 10:59

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.