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');