[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 [email protected].

Liked this Post?
Please Share it!

2 thoughts on “[The Events Calendar] Sorting slides by Event Start Date

  1. Hello,

    I have tried to implement this however it isn’t functioning correctly. Just to verify, is the slider API the same as the slider ID?? If not, where do I obtain the Slider API number? Also, should I be placing code in this window (see screenshot URL in the Website field). Thank you for the help.

    1. Hi Georges,

      Slider API and Slider ID are different. Slider contains Slider ID for example, to show a popup when slider start we can use api[Engine 6 API] “revapi.revstart();” but if a page has multiple sliders this api would attach popup to all of them for that reason we can add an ID to the API “revapi88.revstart();”. Refer to this link to find slider ID: https://www.sliderrevolution.com/faq/custom-sorting-for-post-based-modules/. You can also add custom ID/Classes, and the code should be add to Custom JS section, see this for custom ID/Classes and Custom JS area link: https://www.sliderrevolution.com/manual/custom-css-and-javascript-with-slider-revolution/.

Leave a Reply

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