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

Picture of Amitpal Singh
Amitpal Singh
November 22, 2021
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:

How to Attribute?

Lorem ipsum is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero.
for Example: Website, Social Media, Blogs, ebooks , newsletter, etc.
Lorem ipsum is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero.
Copied!

Got a Question? Check out our FAQ Section.

Your action, our appreciation

It encourage us to give you more valuable content on website.