Add events to team pages
This commit is contained in:
@@ -100,6 +100,7 @@ class SP_Settings_Page {
|
||||
|
||||
<ul class="sp-layout sp-sortable-list ui-sortable">
|
||||
<?php foreach ( $templates as $template => $details ) {
|
||||
if ( ! is_array( $details ) ) continue;
|
||||
$option = sp_array_value( $details, 'option', 'sportspress_' . $this->template . '_show_' . $template );
|
||||
$visibility = get_option( $option, sp_array_value( $details, 'default', 'yes' ) );
|
||||
?>
|
||||
|
||||
@@ -34,6 +34,9 @@ class SP_Calendar extends SP_Custom_Post {
|
||||
/** @var int The season ID. */
|
||||
public $season;
|
||||
|
||||
/** @var int The team ID. */
|
||||
public $team;
|
||||
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
@@ -111,6 +114,16 @@ class SP_Calendar extends SP_Custom_Post {
|
||||
$season_ids = array( $this->season );
|
||||
endif;
|
||||
|
||||
if ( $this->team ):
|
||||
$args['meta_query'] = array(
|
||||
array(
|
||||
'key' => 'sp_team',
|
||||
'value' => array( $this->team ),
|
||||
'compare' => 'IN',
|
||||
),
|
||||
);
|
||||
endif;
|
||||
|
||||
if ( $pagenow != 'post-new.php' ):
|
||||
if ( $this->ID ):
|
||||
$leagues = get_the_terms( $this->ID, 'sp_league' );
|
||||
|
||||
@@ -394,8 +394,17 @@ class SP_Team extends SP_Custom_Post {
|
||||
'posts_per_page' => -1,
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
'meta_key' => 'sp_team',
|
||||
'meta_value' => $this->ID,
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => 'sp_team',
|
||||
'value' => $this->ID,
|
||||
),
|
||||
array(
|
||||
'key' => 'sp_team',
|
||||
'value' => '0',
|
||||
),
|
||||
),
|
||||
);
|
||||
$lists = get_posts( $args );
|
||||
|
||||
|
||||
@@ -303,6 +303,19 @@ if ( ! function_exists( 'sportspress_output_team_lists' ) ) {
|
||||
sp_get_template( 'team-lists.php' );
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'sportspress_output_team_events' ) ) {
|
||||
|
||||
/**
|
||||
* Output the team events.
|
||||
*
|
||||
* @access public
|
||||
* @subpackage Team/Events
|
||||
* @return void
|
||||
*/
|
||||
function sportspress_output_team_events() {
|
||||
sp_get_template( 'team-events.php' );
|
||||
}
|
||||
}
|
||||
|
||||
/** Single League Table ********************************************************/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user