Wordpress WP_Query compare two dates -


i'm trying setup custom post type page 'events' lists out upcoming events , past events. date event stored in custom field using (advanced custom fields) plugin. i'm trying use wp_query , loop through posts have there custom field date (event_date) set after current date. on how achived this?

my effort below. thanks

$today = date('yyyy-mm-dd'); $args  = array( 'meta_query' => array(     array(     'key' => '_acf_event_date',     'value' => ''.$today.'',     'type' => 'date',     'compare' => '>'    ) ), 'post_type' => array(     'events' ), 'posts_per_page' => -1, 'paged' => get_query_var('paged')  ); $query = new wp_query($args); 

loop

ideas?

thanks @rrikesh point me @ database , see format getting saved as. turns out comparing incorrect formats.

changed too.

'meta_query' => array(     array(     'key' => 'event_date',     'value' => date('y-m-d'),     'type' => 'date',     'compare' => '<='    ) 

thanks


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -