Skip to content

Instantly share code, notes, and snippets.

@alimoshen
Last active January 29, 2018 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alimoshen/b3fbf4330f4c53831b03f486deb703e8 to your computer and use it in GitHub Desktop.
Save alimoshen/b3fbf4330f4c53831b03f486deb703e8 to your computer and use it in GitHub Desktop.
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