Support

Account

Home Forums General Issues Sorting Date Range Issue Reply To: Sorting Date Range Issue

  • Thanks John! I adjusted the code a bit and it works great. Here’s what worked for me in case anyone else has this issue.

    $args = array( 
    	'posts_per_page'   => -1,
    	'post_type'     => 'events',
    	'order' => 'ASC', 
    	'meta_query' => array(
    		array(
    			'key' => 'display_on_upcoming_events',
    			'value' => '1',
    			'compare' => '=='
    		),
    		 'date_clause' => array(
    			'key' => 'event_date',
    		'compare' => 'EXISTS'
    					    ),
    					  ),
    					  'orderby' => 'meta_value_num',
    					  'meta_key' => 'event_date', 
    					);