I am trying to get a query to retrieve all the posts where a specific meta_key
does not exist and then create it.
I am having problems finding those posts as the query I am testing does not seem to work.
Here is the code I am using to try to get those posts:
$args = array(
'posts_per_page' => 18,
'cat'=>1955,
'post_status'=>'publish',
'meta_query' => array(
array(
'key' => 'colors',
'compare' => 'NOT EXISTS'
),
));
query_posts($args);
This returns nothing if there are no posts with the key colors
, but returns they ids
of the posts with the key colors
whenever that key is present (the opposite of what I need). I tried with EXIST
instead but no luck.
If someone can tip me on the correct way of creating a query like the one I need I will appreciate it.
Thanks!