From 939ab2e457189328eac297d81f94cbe385b5d2c0 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Thu, 14 Apr 2016 18:56:04 +1000 Subject: [PATCH] Add league and season options to countdown shortcode --- templates/countdown.php | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/templates/countdown.php b/templates/countdown.php index d7ea4162..e75881f1 100644 --- a/templates/countdown.php +++ b/templates/countdown.php @@ -11,6 +11,8 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly $defaults = array( 'team' => null, + 'league' => null, + 'season' => null, 'id' => null, 'title' => null, 'live' => get_option( 'sportspress_enable_live_countdowns', 'yes' ) == 'yes' ? true : false, @@ -24,8 +26,31 @@ if ( isset( $id ) ): $post = get_post( $id ); else: $args = array(); - if ( isset( $team ) ) - $args = array( 'meta_query' => array( array( 'key' => 'sp_team', 'value' => $team ) ) ); + if ( isset( $team ) ) { + $args['meta_query'] = array( + array( + 'key' => 'sp_team', + 'value' => $team, + ) + ); + } + if ( isset( $league ) || isset( $season ) ) { + $args['tax_query'] = array( 'relation' => 'AND' ); + + if ( isset( $league ) ) { + $args['tax_query'][] = array( + 'taxonomy' => 'sp_league', + 'terms' => $league, + ); + } + + if ( isset( $season ) ) { + $args['tax_query'][] = array( + 'taxonomy' => 'sp_season', + 'terms' => $season, + ); + } + } $post = sp_get_next_event( $args ); endif;