Question

My query is currently sorting by end date. How can I make it so it will sort by the start date?

$args = array ('post_type'      => 'events',
           'meta_query'     => array(
                array(
                   'key'        => 'start_date',
                   'value'      => $min_date,
                   'compare'    => '>'
                ),
                array(
                   'key'        => 'start_date',
                   'value'      => $max_date,
                   'compare'    => '<'
                ),
                array(
                   'key'        => 'end_date',
                   'value'      => $current_date,
                   'compare'    => '>'
                )
            ),
           'orderby'        => 'meta_value',
           'order'          => 'ASC'
          );
Was it helpful?

Solution

try adding:

'meta_key' => 'start_date'
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top