From 936743f55c60f2bb27afa59843e55e1ed24af92a Mon Sep 17 00:00:00 2001 From: savvasha Date: Fri, 7 Sep 2018 19:03:46 +0300 Subject: [PATCH] Filter events based on Home and Away Team --- includes/class-sp-calendar.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/includes/class-sp-calendar.php b/includes/class-sp-calendar.php index b34a85d6..2021e321 100644 --- a/includes/class-sp-calendar.php +++ b/includes/class-sp-calendar.php @@ -209,6 +209,7 @@ class SP_Calendar extends SP_Secondary_Post { ); endif; + // If we are showing past meetings filter by team's id and current event date if ( $this->teams_past ): foreach ( $this->teams_past as $team_past ): $args['meta_query'][] = array( @@ -345,6 +346,17 @@ class SP_Calendar extends SP_Secondary_Post { else: $events = null; endif; + + // Filter out unessecary events if we are showing past meetings + if ( $this->teams_past ){ + $events_past = array(); + foreach ( $events as $single_event ) { + if ( get_post_meta( $single_event->ID,'sp_team' ) === $this->teams_past ){ + $events_past[] = $single_event; + } + } + $events = $events_past; + } // Remove any calendar selection filters remove_filter( 'posts_where', array( $this, 'range' ) );