How to only display posts whose meta_value field is not empty?

If you want the meta value to exist and have some value other than an empty string:
 'meta_query' => [
        'relation' => 'AND',
        [
          'key' => 'some_key',
          'compare' => 'EXISTS',
        ],
        [
          'key' => 'some_key',
          'compare' => '!=',
          'value' => ''
        ]
      ] 

Share this post:

Share on facebook
Share on twitter
Share on linkedin
Share on email
Amitpal Singh
Amitpal Singh
Freelance website and application developer. Working from Sangrur Punjab in India.
Follow Amitpal on:

Register

Create your account and post ad