From b4b31f8123fac72d99a91aaf8544af61c1f2efe7 Mon Sep 17 00:00:00 2001 From: Anthony Correa Date: Mon, 20 May 2024 16:40:08 -0500 Subject: [PATCH] add custom event parse request For some reason it doesn't run through sportspress' query parser. i can't figure out why, but this is a way around it. --- includes/sp-event-permalink.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/includes/sp-event-permalink.php b/includes/sp-event-permalink.php index f462050..c88a5f8 100644 --- a/includes/sp-event-permalink.php +++ b/includes/sp-event-permalink.php @@ -74,3 +74,16 @@ function custom_event_rewrite_flush() { } register_activation_hook(__FILE__, 'custom_event_rewrite_flush'); register_deactivation_hook(__FILE__, 'flush_rewrite_rules'); + +// Modify the query to handle custom permalinks and include future posts +function custom_event_parse_request($query) { + $post_type = sp_array_value( $query->query, 'post_type', null ); + if (isset($query->query_vars['post_type']) && $query->query_vars['post_type'] === 'sp_event') { + if (isset($query->query_vars['p'])) { + $query->set('post_type', 'sp_event'); + $query->set('p', $query->query_vars['p']); + $query->set('post_status', array('publish', 'future')); + } + } +} +add_action('pre_get_posts', 'custom_event_parse_request');