Logo Pupungbp.com

Need a WordPress expert help?

How to Check if Meta Value Exist in WordPress Query

Last Updated: February 28, 2019 | Reading Time: < 1 minute

On a loop that performs data from custom meta field, to check if the meta key has value or exist, we can use the following query:

$testimonials = array(
	'post_type' => 'projects',
	'posts_per_page' => 4,
	'meta_key' => 'testimonial',
	'meta_value' => array(''),
	'meta_compare' => 'NOT IN'
);

The above code can be used in WordPress older than 3.5 but it still usable in the latest version of WP, currently 5.1.

Looking for an affordable WordPress solution?

We offer budget-friendly WordPress website development services to meet your needs. Prices start at $10.

Related Posts

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.