Better way of getting ID

This commit is contained in:
Brian Miyaji
2014-01-22 21:01:58 +11:00
parent 7555d78739
commit d7509b8614
12 changed files with 41 additions and 53 deletions

View File

@@ -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>';