The main thing that goes wrong here, is that you overwrite the $teams variable by using a method for it that doesn’t exist. Or, in other words, the parts related to stadiums were not removed from the code or replaced by bits that you need for teams.
I think that the code can be really simple. You can initiate a Football_Pool_Team object directly by passing the team ID. And then use the get_plays() method to get the matches. E.g. something like this (not tested, though):
// Shortcode function
public function display_team_matches($atts) {
// Get team ID from shortcode attribute
$team_id = isset($atts['team_id']) ? intval($atts['team_id']) : 1;
// Instantiate Football Pool classes
$pool = new Football_Pool_Pool;
$team = new Football_Pool_Team($team_id);
// Get matches for the stadium
$fixtures = $team->get_plays();
// Return the matches using Football Pool's print_matches method
return $pool->matches->print_matches($fixtures, 'page team-page');
}You may want to add some extra checks in the code for cases where you supply an invalid or non-existing team ID, but since you are the only one using this, you can also live without it (it will just throw an error and you can fix it by changing the ID in the content).
Thread Starter
nimeck
(@nimeck)
Thank you! This helped. Appreciate the suggestion.
For anyone looking to do the same, you can download the extension here.
