[The Events Calendar] Sorting slides by Event Start Date

This article provides instructions on how to sort the slides by Event Start Date using The Events Calendar plugin.

Slider Revolution is compatible with The Events Calendar plugin, and you can find detailed information on how to integrate the events into the slider by visiting the following link: https://theeventscalendar.com/knowledgebase/integrating-the-events-calendar-with-slider-revolution-and-essential-grid/

If you wish to sort the slides based on the Event dates, you can implement the following custom JS code to the slider.

function modify_slider_order($query, $slider_id) {
 
    // only alter the order for slider with "x" ID
    // Replace 01 with your current slider API number
    if($slider_id == 01) {
 
        // Custom Meta key/name
        $query['meta_key'] = '_EventStartDate';
 
        // Order by Custom Meta values
        $query['orderby'] = '_EventStartDate';
 
        // Calculate order based on:
        // 'NUMERIC', 'CHAR', 'DATE', 'DATETIME', 'TIME'
        $query['meta_type'] = 'DATE';
 
    }
 
    return $query;
 
}
 
add_filter('revslider_get_posts', 'modify_slider_order', 10, 2);

To modify the “Sort Direction,” follow these steps:

  1. Go to SR (Slider Revolution) > Module General Options.
  2. Locate the “Sorting & Settings” section.
  3. Adjust the options as shown in the screenshot below to set the desired sort direction.
[The Events Calendar] Sorting slides by Event Start Date

The Author

KC

Strength does not come from winning. Your struggles develop your strengths. When you go through hardships and decide not to surrender, that is strength.

If you need help with anything related to our plugin, please comment on a post or email me at kc@stage.rvsldr.com.

Liked this Post?
Please Share it!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.