diff --git a/templates/player-statistics.php b/templates/player-statistics.php index 837a472d..46642989 100644 --- a/templates/player-statistics.php +++ b/templates/player-statistics.php @@ -20,8 +20,10 @@ $sections = get_option( 'sportspress_player_performance_sections', -1 ); $leagues = get_the_terms( $id, 'sp_league' ); $positions = $player->positions(); $player_sections = array(); -foreach ( $positions as $position ) { - $player_sections = array_merge( $player_sections, sp_get_term_sections( $position->term_id ) ); +if ( $positions ) { + foreach ( $positions as $position ) { + $player_sections = array_merge( $player_sections, sp_get_term_sections( $position->term_id ) ); + } } // Determine order of sections @@ -36,7 +38,7 @@ if ( 1 == $sections ) { // Loop through statistics for each league if ( is_array( $leagues ) ): foreach ( $section_order as $section_id => $section_label ) { - if ( -1 !== $section_id && ! in_array( $section_id, $player_sections ) ) continue; + if ( -1 !== $section_id && ! empty( $player_sections ) && ! in_array( $section_id, $player_sections ) ) continue; if ( sizeof( $leagues ) > 1 ) { printf( '