I'm trying to run a query that only shows posts if it's meta value has a date string that is LESS than the current date's string. An example is below;
<?php
$current = date('Ymd'); // Eg: today would be 20131011
$date = get_post_meta($post->ID, 'event_date', true); // (Eg; 19690816)
$args (
'post_type' => 'event',
'posts_per_page' => -1,
'meta_query' => array(
'key' => 'event_date',
'value' => $current,
'compare' => '<',
'type' => 'numeric'
)
);
?>
But it doesn't seem to be working.
The $date
value is defined by a meta box and returns a string in the same format as the $current
value above so it's basically just comparing 2 numeric values against each other.
Anyone have any ideas? I've tried it the opposite way, using the greater than symbol and that doesn't want to work either.
I've quadruple checked the post type name, the values, etc and all are correct.