Support

Account

Home Forums Front-end Issues ACF datepicker field get based on date (future/past posts)

Helping

ACF datepicker field get based on date (future/past posts)

  • Hi, I’ve been trying to get the posts from the future based on a datepicker field (date-event), but I can’t make it work. I’ve tried everything… I don’t know what I’m doing wrong.
    This is my code at the moment:

    $today = date('Ymd');
    $args = array(
            'post_type'   => 'post',
            //'meta_key' => 'date_event',
            'posts_per_page' => -1,
            'cat' => '7',
            'orderby' => 'meta_value_num',
            'order' => 'ASC',
            'meta_query' => array(
    			array(
    		        'key'		=> 'date_event',
    		        'compare'	=> '<=',
    		        'value'		=> $today,
    		    ),
    	    ),
        );
  • This is looking for posts <= to today, so before today

    
    array(
    		        'key'		=> 'date_event',
    		        'compare'	=> '<=',
    		        'value'		=> $today,
    		    ),
    

    change that to >=

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.