Query posts with “non set” meta value

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(
‘key’ => ‘instrument’,
// when value is not even set.


$the_query = new WP_Query( $args );

Read more here:: Query posts with “non set” meta value

Leave a Reply

Your email address will not be published. Required fields are marked *