id summary reporter owner description type status priority milestone component version severity resolution keywords cc focuses 23268 NOT EXISTS meta query with OR relation timfield wonderboymusic " With this meta query ( which is trying to exclude posts that have the app_exclude checkbox checked, without excluding posts that don't have it set at all ) {{{ $query['meta_query'] = array( 'relation' => 'OR', array( 'key' => 'app_exclude', 'compare' => 'NOT EXISTS' ), array( 'key' => 'app_exclude', 'compare' => '!=', 'value' => '1' ), ); }}} I'd expect / hope to get this sql. {{{ SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts LEFT JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id AND wp_postmeta.meta_key = 'app_exclude') INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id) WHERE 1 = 1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') AND (wp_postmeta.post_id IS NULL OR (mt1.meta_key = 'app_exclude' AND CAST(mt1.meta_value AS CHAR) != '1')) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0 , 6 }}} but I get this SQL {{{ SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts LEFT JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id AND wp_postmeta.meta_key = 'app_exclude') INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id) WHERE 1 = 1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') AND (wp_postmeta.post_id IS NULL AND (mt1.meta_key = 'app_exclude' AND CAST(mt1.meta_value AS CHAR) != '1')) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0 , 6 }}} Note the... (wp_postmeta.post_id IS NULL '''AND''' (mt1.meta_key = 'app_exclude' AND CAST(mt1.meta_value AS CHAR) != '1'))" defect (bug) closed normal 3.9 Query 3.5 normal fixed has-patch needs-unit-tests meta-query