Support Forum

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Sort by Event Date Reply To: Sort by Event Date

#19756
elvin
Moderator

Hi Gary,

You can add this code based from the previous topic you’ve replied on.

/* Sort Events by Ascending as a Default */
function order_events_by_next_start_date( $wp_query ) {
  if (is_admin()) {
    $post_type = $wp_query->query['post_type'];

    if ( $post_type == 'gd_event') {
      $wp_query->set('orderby', 'event_dates_asc');
      $wp_query->set('order', 'ASC');
    }
  }
}
add_filter('pre_get_posts', 'order_events_by_next_start_date');

Or, add &order=ASC to the settings used in your shortcode:
[wp_show_posts id="14475" settings="orderby=event_dates_asc&order=ASC"]

Mind the text case/capitalization.

Let us know if it works for you.