Skip to content

Commit

Permalink
TMS-1098: date-filter check for selected category
Browse files Browse the repository at this point in the history
  • Loading branch information
eebbi committed Feb 17, 2025
1 parent ded7bec commit d5607ae
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions models/page-combined-events-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,34 @@ public function days() {
\remove_action( 'pre_get_posts', [ __CLASS__, 'modify_event_query' ] );

// Query for all manual events to get all available dates
$dates_query = new \WP_Query( [
$dates_args = [
'post_type' => PostType\ManualEvent::SLUG,
'posts_per_page' => -1,
'meta_key' => 'start_datetime',
'orderby' => 'meta_value',
'order' => 'ASC',
] );
];

// Check if category is selected
$cat = self::get_category_query_var();
if ( ! empty( $cat ) ) {
$dates_args = [
'post_type' => PostType\ManualEvent::SLUG,
'posts_per_page' => -1,
'meta_key' => 'start_datetime',
'orderby' => 'meta_value',
'order' => 'ASC',
'tax_query' => [
[
'taxonomy' => 'manual-event-category',
'field' => 'slug',
'terms' => $cat,
],
]
];
}

$dates_query = new \WP_Query( $dates_args );

// Add query modifications back
\add_action( 'pre_get_posts', [ __CLASS__, 'modify_event_query' ] );
Expand Down

0 comments on commit d5607ae

Please sign in to comment.