Target post_date_gmt if it’s empty or not set

So I’m trying to target some posts to include in my function but I just can’t seem to get it to work.

When I have the meta_query taken out I get 9 results (Works):

$args = array(
‘post_type’ => ‘office’,
‘post_status’ => ‘any’,
‘posts_per_page’ => -1,
‘date_query’ => array(
array(
‘column’ => ‘post_modified_gmt’,
‘before’ => $started,
),
),
);
$the_query = new WP_Query($args);

Then I get one result as below:

object(WP_Post)[1306]
public ‘ID’ => int 50794
public ‘post_author’ => string ’16’ (length=2)
public ‘post_date’ => string ‘2017-10-10 17:24:03’ (length=19)
public ‘post_date_gmt’ => string ‘0000-00-00 00:00:00’ (length=19)

In my OR query, how can I target the post_date_gmt? I’ve tried compare == null, value = ” and I still can’t seem to target it.

Here is the full code:

$args = array(
‘post_type’ => ‘office’,
‘post_status’ => ‘any’,
‘posts_per_page’ => -1,
‘date_query’ => array(
array(
‘column’ => ‘post_modified_gmt’,
‘before’ => $started,
),
),
‘meta_query’ => array(
array(
‘relation’ => ‘OR’,
array(
‘key’ => ‘_setting_update’,
‘value’ => ‘1’,
‘compare’ => ‘==’
),
array(
‘key’ => ‘post_date_gmt’,
‘value’ => ”,
‘compare’ => ‘==’,
),
),
),
);
$the_query = new WP_Query($args);

Read more here:: Target post_date_gmt if it’s empty or not set

Leave a Reply

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