WordPress WP_Query comparing dates in custom field

I am trying to run a WP_Query in WordPress to retrieve posts dated after today using a custom field. My key _mcd_event_date_end has values stored in the m/d/Y format (02/16/2016).

$args = array(
'order' => 'DESC',
'posts_per_page' => -1,
'post_type' => 'mcdevent'
'meta_query' => array(
    'relation' => 'AND',
    array(
        'key'     => '_mcd_event_date_end',
        'value'   => date("m/d/Y"), 
        'compare' => '>=',
    ),
    array(
        'key' => '_mcd_event_type',
        'value'   => 'Other Event',
        'compare' => '=',
    ),
),
);
$other_events = new WP_Query($args);
wp_reset_postdata();

This is the code I am running, and it works for dates posted this year, but not prior. Meaning if I have a post with the _mcd_event_date_end key having a value of something like 4/16/2016 it will show up and if it is something like 2/12/2016 it will not show up. But then anything from 12/31/2015 and before also shows up.

Read More

Thanks for your help and please let me know if there’s any more information I can provide.

Related posts

1 comment

Comments are closed.