Skip to content

Commit dd65f25

Browse files
authored
Merge pull request #53 from Vrishabhsk/fix/VJ-37-events-order-prod
Fix : Set Upcoming Events as Default [ PROD ]
2 parents c4b5f39 + d3de419 commit dd65f25

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

themes/osi/inc/sugar-calendar.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,29 @@ function osi_purchase_button_html( string $button_html, object $event ) {
308308
}
309309
add_filter( 'sc_et_purchase_button_html', 'osi_purchase_button_html', 10, 2 );
310310

311+
/**
312+
* Modify the events archive query.
313+
* Set the default display to upcoming events in an ascending order.
314+
*
315+
* @return void
316+
*/
317+
function osi_modify_events_archive() {
318+
// Bail if in admin
319+
if ( is_admin() ) {
320+
return;
321+
}
322+
323+
// Get post types
324+
$pts = sugar_calendar_allowed_post_types();
325+
326+
// Only proceed if an Event post type
327+
if ( is_post_type_archive( $pts ) && ! isset( $_GET['event-display'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
328+
wp_safe_redirect( '/events/?event-display=upcoming' );
329+
}
330+
}
331+
332+
add_action( 'template_redirect', 'osi_modify_events_archive' );
333+
311334
/**
312335
* Generates default event metadata if ticket price is empty.
313336
*

0 commit comments

Comments
 (0)