I'd like to make a query of custom posts based on a custom field, say instrument
. I need to be able to query only those posts for which the custom field has not been set (i.e. for which the meta value does not exist). Is there a way to achieve this with meta_query
?
Here's the code for the query :
$args = array(
'post_type' => 'my_custom_post_type',
'nopaging' => true
);
$args['meta_query'] = array(
array(
'key' => 'instrument',
// when value is not even set.
)
);
}
$the_query = new WP_Query( $args );