Why Wordpress ignores meta_query conditions?
<p>There is a simple query with two meta-conditions.</p>

<pre><code>$defaults = array(
    'post_type' =&gt; 'products',
    'orderby'   =&gt; 'date',
    'order'     =&gt; 'DESC',
);

if($is_deadline) { // true, I checked
    $defaults['meta_key'] = 'deadline',
    $defaults['meta_type'] = 'NUMERIC',
    $defaults['meta_value'] = (int)current_time( 'Ymd' );
    $defaults['meta_compare'] = '&gt;=';

    $defaults['meta_query'] = array( // this query will be ignored
        'relation' =&gt; 'OR',
        array(
            'key'     =&gt; 'deadline',
            'value'   =&gt; '',
            'compare' =&gt; '='
        )
    );
}
</code></pre>

<p>But I have problem: Wordpress ignores meta_query block. In other words, $query->request looks like this (without compare with empty string):</p>

<pre><code>SELECT adveq_posts.* FROM adveq_posts
INNER JOIN adveq_postmeta ON ( adveq_posts.ID = adveq_postmeta.post_id ) WHERE 1=1  
AND ( 
  ( adveq_postmeta.meta_key = 'deadline' AND CAST(adveq_postmeta.meta_value AS SIGNED) &gt;= '20160629' )
) 
AND adveq_posts.post_type = 'products' 
AND (adveq_posts.post_status = 'publish' 
OR adveq_posts.post_status = 'private') 
GROUP BY adveq_posts.ID 
ORDER BY adveq_posts.post_date DESC 
</code></pre>

<p>This problem fly away if I set relation to 'AND' - meta_query no longer ignored. But I need OR, not AND. I tried another variant, with meta_query only.</p>

<pre><code>$defaults = array(
    'post_type' =&gt; 'products',
    'orderby'   =&gt; 'date',
    'order'     =&gt; 'DESC',
);

if($is_deadline) { // true, I checked
    $defaults['meta_query'] = array(
        'relation' =&gt; 'OR',
        array(
            'key'     =&gt; 'deadline',
            'value'   =&gt; (int)current_time( 'Ymd' ),
            'type'    =&gt; 'NUMERIC',
            'compare' =&gt; '&gt;='
        ),
        array(
            'key'     =&gt; 'deadline',
            'value'   =&gt; '',
            'compare' =&gt; '='
        )
    );
}
</code></pre>

<p>But, in this case Wordpress ignores meta_query so much as possible. Even if relation='AND', problem still exists and WP behavior is exactly the same.</p>

<pre><code>SELECT adveq_posts.* FROM adveq_posts 
WHERE 1=1  AND adveq_posts.post_type = 'structured_products' 
AND (adveq_posts.post_status = 'publish' OR adveq_posts.post_status = 'private') 
ORDER BY adveq_posts.post_date DESC
</code></pre>

<p>Any suggestions? Perhaps this is a WP core bug? This behavior is very strange and illogical.</p>