How to list post with specific custom field which is empty?

I have some posts with custom field 'author', and for some posts that custom field is emty, so I would like to find those posts to delete that custom field for them.

'post_type' => 'post', // Post type is post.
'post_status' => 'publish', // Post is published.
'meta_key' => 'author',
'value'   => '',
'meta_compare' => '=',

'posts_per_page' => 100, // Posts per page.
'caller_get_posts'=> 100 // Get posts per page
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>

<?php // my code; ?>

  • Is the field empty or not assigned. also, you are using caller_get_posts wrongly. It is deprecated and replaced by ignore_sticky_posts Commented Jun 12, 2016 at 11:44
  • I wish to find posts with emty fields. That custom field exist in most posts with some value, but in some posts value is emty. Commented Jun 12, 2016 at 11:55

1 Answer 1


You probably need the NOT EXISTS meta_compare value. This will test if a meta value exists or not for that particular key.

Also, as I pointed out in comments, caller_get_posts is long time deprecated, a notice you should have clearly recieved if you had debubbing turned on. The correct parameter is ignore_sticky_posts and accepts 0 (false) or 1 (true)


One issue I missed is, value should be meta_value when not using a proper meta_query

  • I tried with NOT EXISTS meta_compare value, still I can not get posts with emty value. Commented Jun 12, 2016 at 13:56
  • One thing I missed, value should be meta_value. Try that with meta_compare being = and NOT EXISTS Commented Jun 12, 2016 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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