Better way of getting ID
This commit is contained in:
@@ -2,13 +2,14 @@
|
||||
if ( !function_exists( 'sportspress_team_columns' ) ) {
|
||||
function sportspress_team_columns( $id = null ) {
|
||||
|
||||
if ( ! $id ):
|
||||
global $post;
|
||||
$id = $post->ID;
|
||||
endif;
|
||||
if ( ! $id )
|
||||
$id = get_the_ID();
|
||||
|
||||
$leagues = get_the_terms( $id, 'sp_league' );
|
||||
|
||||
if ( ! $leagues )
|
||||
return false;
|
||||
|
||||
$output = '';
|
||||
|
||||
// Loop through data for each league
|
||||
@@ -19,16 +20,14 @@ if ( !function_exists( 'sportspress_team_columns' ) ) {
|
||||
if ( sizeof( $data ) <= 1 )
|
||||
continue;
|
||||
|
||||
if ( sizeof( $leagues ) > 1 )
|
||||
$output .= '<h4 class="sp-team-league-name">' . $league->name . '</h4>';
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
$output .= '<table class="sp-team-columns sp-data-table">' . '<thead>' . '<tr>';
|
||||
$output .= '<h4 class="sp-table-caption">' . $league->name . '</h4>' .
|
||||
'<table class="sp-team-columns sp-data-table">' . '<thead>' . '<tr>';
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
$output .= '<th class="data-' . $key . '">' . $label . '</th>';
|
||||
|
||||
Reference in New Issue
Block a user