Is the problem that your filter is working but the sort doesn’t work? If so, I believe it’s because you need to specify which meta_key
you’d like to sort by. For example, you’ll need to add either event_end_date
or one_day_event_date
as the value for meta_key at the top level array.
Try this…
<?php
$currentdate = date("Ymd",mktime(0,0,0,date("m"),date("d")-1,date("Y")));
$args = array(
'post_type' => 'event',
'meta_key' => 'event_end_date', // this is where you specify which meta field to sort on
'meta_query' => array(
array(
'key' => 'event_end_date',
'value' => $currentdate,
'compare' => '>',
'type' => 'DATE'
),
array(
'key' => 'one_day_event_date',
'value' => $currentdate,
'compare' => '>',
'type' => 'DATE'
)
),
'orderby' => 'meta_value_num',
'order' => 'ASC'
);
$query = new WP_Query( $args );
?>
If you need to sort them both by a start date, for example, I would actually give them both a date called start_date
and sort by that… Then the one day events would just not have an end_date (or maybe the end date can just be the same as the start date).