Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kadimi/daa099a5c9fc2ac15a8a185464400b5c to your computer and use it in GitHub Desktop.
Save kadimi/daa099a5c9fc2ac15a8a185464400b5c to your computer and use it in GitHub Desktop.
SportsPress - Customize past events list columns
<?php
/**
* Customize past events list columns.
*/
add_action( 'init', function() {
/**
* Desired columns.
*
* @var array
*/
$columns = [
'event',
'time',
'results',
'league',
'season',
];
/**
* Only run once.
*/
static $overridden = false;
/**
* Capture.
*/
add_action( 'sportspress_before_template', function( $template_name, $_, $__, $args ) use ( $overridden ) {
if ( $overridden
|| $template_name !== 'event-list.php'
|| $args[ 'title' ] !== __( 'Past Meetings', 'sportspress' )
) {
return;
}
ob_start();
}, 10, 4 );
/**
* Override.
*/
add_action( 'sportspress_after_template', function( $template_name, $_, $__, $args ) use ( &$overridden ) {
if ( $overridden
|| $template_name !== 'event-list.php'
|| $args[ 'title' ] !== __( 'Past Meetings', 'sportspress' )
) {
return;
}
$overridden = true;
ob_get_clean();
sp_get_template( 'event-list.php', array(
'title' => __( 'Past Meetings', 'sportspress' ),
'show_title' => true,
'teams_past' => get_post_meta( get_the_ID(), 'sp_team' ),
'date_before' => get_post_time( 'Y-m-d', true ),
'title_format' => 'homeaway',
'time_format' => 'separate',
'columns' => $columns,
'order' => 'DESC',
'hide_if_empty' => true,
) );
}, 10, 4 );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment