I'm using the code below to pull upcoming webcasts onto the homepage. It works fine, except for one anomaly - it's not ordering correctly by date.
The dates are stored as a Unix timestamp, so comparing as number should - I'd have thought - be no problem. However, as an example, the three webcasts that the code below is pulling through at the moment have date values of:
... and that't the order they're displayed in. Even I can see that's not numerically ordered, and my maths is rubbish.
So what's going on?
$args = array( 'post_type' => 'webcast', 'meta_key' => 'webcast-date', 'meta_value' => array( time(), strtotime('+60 days') ), 'meta_type' => 'numeric', 'meta_compare' => 'BETWEEN', 'orderby ' => 'meta_value_num', 'order' => 'ASC' ); $webcasts = new WP_Query($args);