Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WordPress query exclude custom field value and when it doesn't exist
$query = array(
'post_type' => 'profiles',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'disable_profile',
'compare' => '==',
'value' => 'disabled',
),
array(
'key' => 'disable_profile',
'compare' => 'NOT EXISTS',
),
),
'order' => ASC,
'posts_per_page' => $post_per_page,
'paged' => $paged
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment