Revolution Slider Orderby Two Custom Fields

I have create Revolution Slider which load the custom post type, Events. There are two custom fields, Event Start Date and Event End Date. I would like to display order by Start and End date. Because now only able order by Start date and if same Start date, then will order by Title.

Here is what I found from Revolution Slider website:

https://www.themepunch.com/faq/sort-options-post-based-sliders/

function modify_slider_order($query, $slider_id) {
    if($slider_id == 4) {
        $query['meta_key'] = 'event_start_date';
        $query['orderby'] = 'event_start_date';
        $query['meta_type'] = 'DATE';
        $query['order'] = 'ASC';
    }
        return $query;
}
add_filter('revslider_get_posts', 'modify_slider_order', 10, 2);

However, I unable able to add array to 'orderby'. According this:

http://www.billerickson.net/wp-query-sort-by-meta/

'orderby'  = array(
    'event_start_date' = 'ASC',
    'event_end_date' = 'ASC',
),

Can anyone give me some idea, how I change the 'orderby'?

Thanks!

Topic advanced-custom-fields order wp-query custom-field Wordpress

Category Web


To order by event-end date or start date, your write separate function and call them as per requirement. For example if user clicks on order by start then start function should be called.

switch($orderby){
case: 'event-start':
# your code
/*
 $query['meta_key'] = 'event_start_date';
        $query['orderby'] = 'event_start_date';
*/
break;
case 'event-end':
#your code
/*
 $query['meta_key'] = 'event_end_date';
        $query['orderby'] = 'event_end_date';
*/
break;

}

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.