Support

Account

Home Forums General Issues Filtering posts by date (Date Picker) Reply To: Filtering posts by date (Date Picker)

  • It’s not working for me either!

    I want to show posts with event_date field greater or equal than today.
    Here’s my code, but the posts are not filtered. I tried without type or with NUMERIC or CHAR:

    
    $today = date('Ymd');
    $meta_query = array(
    	array(
    	'key' => 'event_date',
    	'compare' => '>=',
    	'value' => $today,
    	'type' => 'CHAR'
    	)
    );
    
    $args = array(
    	'post_type' => 'post',
    	'meta_key' => 'event_date',
    	'orderby'   => 'meta_value',
    	'order' => 'ASC',
    	'paged' => 1,
    	'meta-query' => $meta_query
    );
    
    $wp_query = new WP_Query($args);