List Matches by Team Shortcode (extension)
-
I tried to follow your lead with Chat GPT to make a shortcode that lists all the matches by team. However it outputted something very different.
Then I tried to alter the Venues extension code from the other post, however it did not work. Could you tell me if there is something I screwed up here?
Shortcode I entered was: [team_matches team_id=”14″]
<?php /* Plugin Name: Football Pool - Matches by Team Shortcode Description: This plugin adds a shortcode to display matches for a certain team. */ // Main plugin class class Team_Matches_Shortcode { public function __construct() { // Hook to plugins_loaded to ensure dependencies are loaded add_action('plugins_loaded', array($this, 'init')); } // Initialize the plugin public function init() { // Add shortcode add_shortcode('team_matches', array($this, 'display_team_matches')); } // Shortcode function public function display_stadium_matches($atts) { // Instantiate Football Pool classes $pool = new Football_Pool_Pool; $team = new Football_Pool_Team; // Get team ID from shortcode attribute $team_id = isset($atts['team_id']) ? intval($atts['team_id']) : 1; // Get stadium details $team = $team->get_stadium_by_id($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'); } } // Instantiate the plugin class new Team_Matches_Shortcode();
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘List Matches by Team Shortcode (extension)’ is closed to new replies.