I have a wp_query that gets all custom post types in ascending order from today, to list some events on a site of mine. While this works fine:
$args = array( 'post_type' => 'events',
'posts_per_page' => 5,
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_key' => 'my_special_date',
'meta_value' => date('Ymd',strtotime("today")),
'meta_compare' => '>=' );
I am not getting the same results when I convert this to using meta_query, like so:
array( 'post_type' => 'events',
'posts_per_page' => 5,
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'my_special_date',
'value' => date('Ymd',strtotime("today")),
'compare' => '>=',
'type' => 'NUMERIC'
)
)
);
Note that I'm not comparing dates, I'm comparing numbers, as the date is in the Ymd format. the meta key is in this format. I am having some rather odd results from this - I can't quite work out what's wrong. Anything look obviously wrong to any of you?