Dear Metabox. I'm trying to set up a comparison datetime, so as to only show current or future events posts. I'm failing and not sure what I'm doing wrong. I'm presuming the 'timestamp' => true, option has been added to metabox.io for precisely this particular sort of comparison, but I can't get it to work. Any help would be hugely appreciated.
My reasoning as follows:
1) the datetime meta_box field is set to save in the database with 'timestamp' option
array(
'name' => 'Date',
'desc' => 'For events over a stretch of time or taking place on more that one day, this should be the END DATE.',
'id' => $prefix . 'event-date',
'type' => 'datetime',
'timestamp' => true,
),
2) Second, my query
If my thinking is correct - this should return posts with a date equal to or greater than the current date - but no show of any posts.
<?php
$type = 'npl-event';
$key = 'poetrylibrary_event-date';
$today = current_time('timestamp');
$args = array (
'post_type' => $type,
'meta_key' => $key,
'meta_value' => $today,
'meta_query' => array(
'key' => $key,
'value' => $today,
'compare' => '>=',
'type' => 'NUMERIC'
)
);
$homequery1 = clone $wp_query;
$wp_query = null;
$wp_query = new WP_Query($args);
if ( $wp_query->have_posts() ) :
/* Start the Loop */
while ( $wp_query->have_posts() ) : $wp_query->the_post();
etc…