How To’s

Learn More

Getting started with Sports Bench can seem a bit overwhelming, and that’s okay. Below are a number of how to’s I’ve written to help you get started. They range from basic setup steps to more complicated integrations. If you still need help, feel free to use the contact form at the bottom to ask me any question you have.

To read tutorials on more complicated things, please view the Tutorials page.

Installation

So you’ve bought Sports Bench? Cool. Here’s how to install it and get on your way to creating a cool sports website.

Plugin

Via WordPress Dashboard
  1. If you purchased the plugin/theme package, unzip the “sports-bench” directory that comes with the download. If you purchased the plugin only, ignore this step.
  2. In the WordPress admin area, go to Plugins->Add New. Then hit “Upload Plugin” at the top of the subsequent page.
  3. Select the zipped plugin directory (i.e. sports-bench-1.0.zip) and hit “Install Now”.
  4. After the plugin is installed, click “Activate” to start using the theme.
  5. Go to the “Setup” section of this ReadMe file to get the plugin rolling for your use.
Via FTP Upload
  1. If you purchased the plugin/theme package, unzip the “sports-bench” directory that comes with the download. If you purchased the plugin only, ignore this step.
  2. Unzip the zipped plugin directory (i.e. sports-bench-1.0.zip).
  3. Upload the sports-bench directory inside the now-unzipped directory to the plugin directory on your site (located inside of the wp-content directory).
  4. In the WordPress admin area, go to the Plugins page and hit “Activate” underneath the Sports Bench listing on the page to begin using the theme.
  5. Go to the “Setup” section of this ReadMe file to get the plugin rolling for your use.

Theme

Via WordPress Dashboard
  1. If you purchased the plugin/theme package, unzip the “sports-bench” directory that comes with the download. If you purchased the theme only, ignore this step.
  2. In the WordPress admin area, go to Appearance->Themes. Click the “Add New” button at the top of the page and then hit “Upload Theme” at the top of the subsequent page.
  3. Select the zipped theme directory (i.e. sports-bench-1.0.zip) and hit Install now.
  4. After the theme is installed, click “Activate” to start using the theme.
Via FTP Upload
  1. If you purchased the plugin/theme package, unzip the “sports-bench” directory that comes with the download. If you purchased the theme only, ignore this step.
  2. Unzip the zipped theme directory (i.e. sports-bench-1.0.zip).
  3. Upload the sports-bench directory inside the now-unzipped directory to the themes directory on your site (located inside of the wp-content directory).
  4. In the WordPress admin area, go to Appearance->Theme and hit “Activate” underneath the Sports Bench listing on the page to begin using the theme.
Show How To

Setting Up Sports Bench

So now you’ve got the plugin installed and activated. Before we get too far along, we need to set up a few plugin settings so that you’re ready to go.

  1. Go to the Sports Bench Options page after activating the plugin. The link can be found in the admin menu on the left side.
  2. First, select a sport. Currently, baseball, basketball, (American) Football, Hockey and Soccer (Football) are supported. Please note that if you select a sport, comeback to the option and change it, all games will be lost.
  3. Add the current season. The default is the current year. Please make note of how you format the year(s) here. You’ll need it when you start to create games later on. Make sure to update this setting when you start a new season.
  4. Determine whether or not you want to display games by week or not. This option determines how games are shown on the scoreboard. If you don’t select this option, you can disregard the “Week” field when creating games. Otherwise, next enter the current week of the season. You’ll update this setting a lot.
  5. If you have a or want a page to show team pages, select the page that is using the team page template. This will direct team links to this page. If you haven’t created the page for the teams, you can come back to this later. We’ll get into more detail later on in the guide.
  6. If you have a or want a page to show player pages, select the page that is using the player page template. This will direct player links to this page. If you haven’t created the page for the players, you can come back to this later. We’ll get into more detail later on in the guide.
Show How To

Creating a Division

All right, now we’ve got our settings taken care of we can start adding some data. At first you’ll probably be tempted to create teams right now, but most leagues divide their teams up into divisions, conferences or leagues, so let’s start there first. This way it will be much easier once we start adding teams.

  1. To start adding divisions, hover over the “Teams” item in the menu in the admin area of your site. Then click on “Divisions” in the submenu that appears.
  2. The divisions page is set up nearly identical to the categories page in WordPress where the divisions are listed on the right and you can add divisions or conferences on the left.
  3. To add a division or conference, first fill out the name of the division or conference.
  4. Then select if this is a division or a conference.
  5. If this is a conference, select the color for the conference. This is optional, but the color appears a border between the table head and table body wherever the standings appear.
  6. If this is a division, select the conference the division belongs to. The recommended practice is to add conferences first and then add divisions, if that is your set up.
  7. Then hit save. The page will reload and your new item will show up on the left. Repeat this process until all of your divisions and conferences are added.
Show How To

Creating a Team

At this point we’ve installed the plugin, got the settings taken care of and added our conferences and divisions. Now it’s finally time to add in the teams.

  1. To start adding teams, hover over the “Teams” item in the admin area of your site. Then click “Add New” in the submenu that appears.
  2. Starting at the top, add the full team name (i.e. Texas Rangers, Seattle Seahawks, FC Dallas).
  3. Then enter the team location. If the team has a location and nickname, put just the city or state (i.e. Texas, Seattle). If the team has no nickname, like FC Dallas or D.C. United, put the full name here again and leave the nickname field next blank.
  4. Enter in the nickname of the team if there is one (i.e. Ranger, Seahawks).
  5. Next enter the three or four letter abbreviation of the team (i.e. TEX, SEA, FCD).
  6. Next select whether the team is active or inactive. The default setting is always active. This only changes to inactive if the team takes a hiatus or folds.
  7. Then enter the city and the state where the team is located.
  8. Next enter the stadium name and the capacity of the stadium.
  9. Then enter the name of the head coach.
  10. Next select what division or conference the team is placed in.
  11. Then enter the primary and secondary colors for the team.
  12. Next, on the right hand side, upload the team’s logo.
  13. Then you can add a photo of the team below the logo. This is an optional item.
  14. Finally, hit save at the bottom. You’ve now created your first team. Congrats! Now repeat these steps to add your remaining teams.
Show How To

Creating a Player

So we’ve added our teams. Now it’s time to add our players to these teams.

  1. To start adding players, hover over the “Players” item in the admin area of your site. Then click “Add New” in the submenu that appears.
  2. Enter in the first and last name of the player.
  3. Then select the team the player plays for, or select “Free Agent” if the player has no team.
  4. Next use the date picker to select the player’s birthday.
  5. Then either enter or select the position the player page.
  6. Next add the height and weight of the player if you want to.
  7. Then enter the city and state name of the player’s hometown if you so wish.
  8. Add a photo of the player on the right side of the page, if you wish.
  9. Finally, hit save at the bottom. You’ve now created your first player. Congrats. Now repeat these steps to add your remaining players.
Show How To

Creating a Game

So we’ve added our teams and their players. Now it’s time to add games to the schedule. This is the most complicated of the admin pages associated with the plugin, but if you follow these steps, you’ll have no issue adding games and game stats.

  1. To start adding games, hover over the “Games” item in the admin area of your site. Then click “Add New” in the submenu that appears.
  2. Select the home and away teams for the game.
  3. Then select whether this game is a scheduled game, a game in progress or a game that is final.
  4. If this is a game that’s in progress, another section will appear below. Here you’ll enter the current score for the home and away teams and the current time and period (or minute of the match for soccer or inning for baseball) of the game.
  5. In the game information row, enter the season the game is taking place in. If you’re sorting your games by week, add the week number. Then add the date and time of the game and the attendance of the game (if applicable).
    • If this game is listed as a scheduled game, you don’t need to go any further. Hit save right here and you’re done! You’ve added your first game. Otherwise, continue on.
  6. In this next section, add the scoreline for the game. If this is a baseball game, enter in the runs, hits, errors and men/women left on base. Otherwise, enter the scoring by quarter, period or half. The final column on the right will automatically add up the total for each team.
  7. Next add the game/match events for the game. This differs from sport to sport, but the column headings wil point you in the right direction. You can add as many game events as needed with the button at the bottom. You can also remove game events with the remove button at the end of each row.
    • Note: Basketball games do not have this section.
    • If this game is listed as an in-progress game, you don’t need to go any further. Hit save right here and you’re done! You’ve added your first game. Otherwise, continue on.
  8. Then add in the team stats for the game. Again, this differs depending on the sport, but the titles in the center will help you along.
  9. Next add in the individual player stats for the home and away teams. The players will be loaded in a dropdown on the left when you select the teams at the top. Again, the stats you’ll need to enter differ depending on the sport, but the column headings will guide you along. You can add as many players as you need with the button at the bottom of each section. You can also remove players with the remove button at the end of each row.
  10. Finally, hit the save button at the bottom of the page. You’ve now created your first game complete with all of the stats. Congrats! Now just repeat the process whenever you need to add or edit games.
Show How To

Creating a Playoff Bracket

Okay so now an entire season has gone by and it’s time for playoffs. (And yes Jim Mora, we’re talking about playoffs). Sports Bench makes it easy for you to create playoff brackets to show off who your one true champion really is.

  • To add a playoff bracket, hover over the “Playoffs” item in the admin area of your site. Then click “Add New” in the submenu that appears.
  • Next give the bracket a name. Then select the number of teams that will be in the tournament, select whether it’s a single or double elimination tournament and then select the season the bracket takes place in.
  • For each playoff match up, select both teams from the dropdowns provided. Give each of them their seeding (if applicable). Then select whether this is a one, two, three, five or seven game series. Finally, select the game that applies to each game in the series from the dropdowns below.
  • Repeat the previous step until the bracket is filled out as much as it can be. The score section on the right will update automatically, but you will have to select the winners by hand like the previous step.
  • When you’re done, hit save. And that’s it. You’ve created your first playoff bracket!
Show How To

Adding Scoreboard, Standings and Stats Pages

All right, so we’ve got the plugin installed and setup. We have our divisions, teams, players and some games. Now how will we display this data. Fortunately, Sports Bench makes it easy for you to display standings, scoreboards and stats leaderboards on pages (and even posts) thanks to shortcodes. This section will take you through how to do that.

  • First start a new page or post. Then click the “SB” logo near the top of the visual editor. This will open up a modal where you can select a number of different shortcodes.
  • If you want to add a scoreboard, select “Scoreboard” and then hit insert. Now when you view the page or post, a scoreboard will be displayed.
  • If you want to add standings, select “Standings” and then hit insert. Then a few options will appear below the editor. If it doesn’t appear right away, give it a few seconds. In the options, you can show league, conference and division standings and show home, away, division and conference records and points for and against and points differential. You can add and remove items if you need to using the buttons in the options.
  • If you want to add a stats leaderboard, select “Stats” and then hit insert. Then an options panel will appear below the editor. Here, you can chose which stats show up on the page. You can add as many stats as you like to the page.
  • That’s it. You can create pages that show a scoreboard, standings and stats without writing a single line of code!
Show How To

Using the Shortcodes

But your shortcode options aren’t just limited to standings, you can also use shortcodes to show playoff brackets, game information, players and teams.

  • To begin using a shortcodes, first start a new page or post. Then click the “SB” logo near the top of the visual editor. This will open up a modal where you can select a number of different shortcodes.
  • If you want to add a game shortcode, select “Game” and then select a season. From there, select a game from that season. The shortcode will then show the teams competing in the game as well as the time, date and location of the game. If the game is finished and has a recap, a link to the recap will show as well.
  • If you want to add a player shortcode, select “Player” and then select a player from the list that appears. The shortcode will display the player’s photo and information and their recent stats.
  • If you want to add a team shortcode, select “Team” and then select a team from the list that appears. The shortcode will display the team’s logo and information and their recent games and upcoming schedule.
  • If you want to add a playoff shortcode, select “Playoff Brackets” and then select a playoff bracket from the list that appears. This will display the bracket in table form on the front end.
  • If you want to add a rivalry shortcode, select “Rivalry” and then select the two teams that you want to display stats for. This will display the series records between the two teams and their recent results against each other.
  • If you want to add a team page shortcode, select “Team Page”. Next, please find the “Creating a Team Page” section of the guide and follow those instructions.
  • If you want to add a player page shortcode, select “Player Page”. Next, please find the “Creating a Player Page” section of the guide and follow those instructions.
  • If you want to add a game recap shortcode, select “Game Recap” and then select the game you want to show a recap for.
  • That’s it. You can now display a lot of cool information in your posts and pages without writing a single line of code!
Show How To

Using the Widgets

Want to display information that appears in the sidebar wherever your viewers go? Sports Bench has widgets so you can display a scoreboard, standings and stats on every page with a widget area.

  • Navigate to the Widgets page in the admin area.
  • To add a scoreboard widget, click and drag the “Sports Bench Scoreboard” widget to the desired widget area. Give it a title and hit “Save”. That’s it.
  • To add a standings widget, click and drag the “Sports Bench Standings” widget to the desired widget area. Give it a title, select whether it will show the league, conference or division standings and then hit “Save”. That’s it.
  • To add a stats widget, click and drag the “Sports Bench Statistic” widget to the desired widget area. Give it a title, select which statistic to show and then hit “Save”. That’s it.
Show How To

Setting Up the Team Page Template

Okay so you’ve created a new page template and shown player information. Now we’re going to do the same for teams, but the level of difficulty is going to go up a bit. But don’t worry. Once again, if you follow these directions, you’ll be feeling like a real programmer by the time it’s over. And if you want, there’s a shortcode you can use to create the team page instead.

Using the Team Page Shortcode

  1. First, create a new page. Then in the new page create a new shortcode. To do this, click the “SB” button in the TinyMCE editor at the top.
  2. In the window that now appears, select “Team Page” and then insert. Then hit “Publish”.
  3. Next, navigate to the Sports Bench Options page. It should be in the menu on the left in the admin.
  4. In the options page, select your new page for the Team Page option and then hit save.
  5. After that, go to the permalinks page. This can be found under the Settings section in the admin. Don’t tough your permalinks, but hit save at the bottom. This will reset the necessary redirects to make the page work.
  6. And that’s it. Your team page is ready to go. And you didn’t even need to write a single line of code.

Using a Team Page Template

Introducing the Team Class

Before we get going too far, let’s introduce the Sports_Bench_Team class.

Once again, if you’re not too familiar with PHP or object-oriented programming, just know that adding the following to your code essentially calls the team from the database and populates it attributes without you having to write more code.

<?php $team = new Sports_Bench_Team( (int){{team_id}} ); ?>

Note that the team id will need to be an actual integer number.

From here, you can get the team name, location and so much more. In fact, here’s a list of the available attributes you can call, plus one function we’ll use to set up this page.

  • $team->team_id
  • $team->team_name
  • $team->team_location
  • $team->team_nickname
  • $team->team_abbreviation
  • $team->team_active
  • $team->team_city
  • $team->team_state
  • $team->team_stadium
  • $team->team_stadium_capacity
  • $team->team_head_coach
  • $team->team_logo
  • $team->team_photo
  • $team->team_division
  • $team->team_primary_color
  • $team->team_secondary_color
  • $team->player_slug
  • $team->team_slug
  • $team->get_schedule()
  • $team->get_roster()
  • $team->get_team_photo()
  • $team->get_division_name()

So now that we’ve gone over something we’ll be using here, let’s start building the player page, shall we? If you want to learn more about the Player class and the other classes, please visit the codex page on the Sports Bench website.

Building the Team Page

Like the player page, creating the team page involves creating a new page template. It’s a simple concept in WordPress, but if you’re unfamiliar with it, you can read this, this and this tutorial on how to do that. Otherwise, let’s get started.

  1. So first off, create a new page template in your theme’s main directory. Name it page-team.php
  2. Next, copy the contents of your theme’s page.php file and paste it into this new page template file.
  3. At the top underneath the opening php tag, paste the following:
    Template Name: Team
  4. Now, this is where things get a bit trickier. In this file, look for the get_sidebar() function. If this is wrapped in a div tag that has a class or id of “widget” or sidebar, then don’t do anything with it. Otherwise, find your theme’s sidebar.php In this file look for a div tag with a class or id of “widget” or “sidebar”. Copy this div and paste it in the new template file above the get_sidebar function. Make sure the closing </div> tag is there as well.
  5. Once you’ve done that, take a quick breather. We’re going to divide the rest of this into two parts: the main body and the sidebar.

Building the Main Body of the Page

  1. Like the player page, find the loop and delete everything within either a main or article div. Then inside of that, paste the following lines of code:
    					<?php if ( class_exists( 'Sports_Bench_Team' ) ) { ?>
    						<?php if ( get_query_var( 'team_slug' ) ) { ?>
    						<?php } else { ?>
    						<?php } ?>
    					<?php } ?>
    
  2. Then inside the else part of the statement, paste the following code: <?php echo sports_bench_show_team_listing(); ?>.
  3. The rest of this section will deal with code going inside the <?php if ( class_exists( 'Sports_Bench_Team' ) ) { ?> section.
  4. To show the team photo, insert the following lines:
    				<div class="team-photo">
                    	<?php echo $team->get_team_photo( 'team-photo' ); ?>
    				</div>
    
  5. To show the team logo, insert the following lines:
    					<div class="team-logo">
    						<?php echo $team->get_team_photo( 'team-logo' ); ?>
    					</div>
    
  6. To show the team name, insert the following lines:
    					<div class="team-name">
    						<h1 class="team-title" style="color:<?php echo $team->team_primary_color; ?>"><?php echo $team->team_name ?></h1>
    					</div>
    
  7. Then, to show the team stats, insert the following lines:
    				<div id="team-stats" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
    					<h4><?php echo get_option( 'sports-bench-season-year' ) . ' ' . __( 'Stats', 'sports-bench' ); ?></h4>
    					<?php echo sports_bench_get_players_stats_table( sports_bench_get_players_stats( $team->team_id,  '"' . get_option( 'sports-bench-season-year' ) . '"' ) ); ?>
    				</div>
    
  8. Finally, to show the team’s roster, insert the following lines:
    				<div id="team-roster" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
    					<h4><?php _e( 'Roster', 'sports-bench' ); ?></h4>
    					<?php echo sports_bench_show_roster( $team->team_id ); ?>
    				</div>
    
  9. All right, that’s it for the main body of the page template. Now let’s finish off the template with the sidebar.

Adding in the Sidebar

This part will be a bit challenging, but again, if you follow the directions here, you’ll do just fine. If you want, you can use this code to sort of give you a guide through what it should look like.

  1. First we need to add a conditional to see if this is a page for a single team or not. So where the get_sidebar function is in your page template, place the lines of code below. If the function is wrapped in a div with a class of “widgets” or “sidebar”, place this code inside that div and disregard that same div in the following code.
    				<?php if ( isset( $team ) ) { ?>
    					<div id="sidebar1" class="sidebar">
    					</div>
    				<?php } else { ?>
    					<?php get_sidebar(); ?>
    				<?php } ?>
    

    It should go without saying that this will replace the original get_sidebar function in your template file.

  2. The remainder of the code will go inside the <?php if ( isset( $team ) ) { ?> section. Now, to show the schedule, place the following lines of code:
    				<aside id="schedule-info" class="widget" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
                    	<h4 class="widgettitle"><?php echo $team->team_name . ' ' . get_theme_mod( 'sports-bench-season-year' ) . ' ' . __( 'Schedule', 'sports-bench' ); ?></h4>
    					<?php echo sports_bench_show_team_schedule( $team->team_id ); ?>
                    </aside>
    
  3. To show the division or conference standings for the team, place the following lines of code:
    				<aside id="standings" class="widget" style="border-top: 2px solid <?php echo $team->team_secondary_color; ?>">
                        <?php global $wpdb;
                        $table = $wpdb->prefix . 'sb_divisions';
                        $querystr = "SELECT * FROM $table WHERE division_id = $team->team_division;";
                        $division = $wpdb->get_results($querystr);
                        $division_title = $division[ 0 ]->division_name . ' ' . __( 'Standings', 'sports-bench' ); ?>
                        <h4 class="widgettitle"><?php echo $division_title; ?></h4>
    					<?php echo sports_bench_team_division_standings( $team->team_division ); ?>
                    </aside>
    
  4. Finally, to show some more team information, add the following lines of code:
    				<aside id="team-info" class="widget clearfix" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
                        <h4 class="widgettitle"><?php _e( 'Team Info', 'sports-bench' ); ?></h4>
    					<?php echo sports_bench_show_team_info( $team->team_id ); ?>
                    </aside>
    

Setting up the Team Template

Okay, we’re almost done with the team page template, but now we need to add the actual page to the site.

  1. Create a new page and name it “Teams”.
  2. On the right-hand side, look for “Page Attributes”. Then select “Team”. Then hit publish.
  3. Next, go to Sports Bench Settings. Find the Team Page setting and then select this newly created page. Hit “Publish”.
  4. After that, go to the permalinks page. This can be found under the Settings section in the admin. Don’t tough your permalinks, but hit save at the bottom. This will reset the necessary redirects to make the page work.
  5. Now navigate to your newly created team page and enjoy your hard work. You deserve it.

That’s it! You’ve now completed creating a template for the teams in your league. It’s now a one-stop-shop for all team information. Confidence in your coding skills continuing to go up? Great! We’re about to take another step up in difficulty. But you’ll do fine.

Show How To

Setting Up the Player Page Template

Okay, so you’re almost complete getting everything going with your website and Sports Bench. But now we’re getting into the challenging part. However, there’s good news. With Sports Bench 1.3, you can add a player page template with a simple shortcode. Or you can learn and dig into the code and do it that way. Both ways will be shown here.

Using the Player Page Shortcode

  1. First, create a new page. Then in the new page create a new shortcode. To do this, click the “SB” button in the TinyMCE editor at the top.
  2. In the window that now appears, select “Player Page” and then insert. Then hit “Publish”.
  3. Next, navigate to the Sports Bench Options page. It should be in the menu on the left in the admin.
  4. In the options page, select your new page for the Player Page option and then hit save.
  5. After that, go to the permalinks page. This can be found under the Settings section in the admin. Don’t tough your permalinks, but hit save at the bottom. This will reset the necessary redirects to make the page work.
  6. And that’s it. Your player page is ready to go. And you didn’t even need to write a single line of code.

Using a Player Page Template

Introducing the Player Class

Before we get going too far, let’s introduce a simple concept that you’ll use here and elsewhere if you want to customize your site even further. Sports Bench comes with three classes: Sports_Bench_Game, Sports_Bench_Player and Sports_Bench_Teams. Here we’ll just look at the player class.

If you’re not too familiar with PHP or object-oriented programming, just know that adding the following to your code essentially calls the player from the database and populates it attributes without you having to write more code.

<?php $player = new Sports_Bench_Player( (int){{player_id}} ); ?>

Note that the player id will need to be an actual integer number.

From here, you can get the player’s first name, last name and so much more. In fact, here’s a list of the available attributes you can call, plus one function we’ll use to set up this page.

  • $player->player_id
  • $player->player_first_name
  • $player->player_last_name
  • $player->player_photo
  • $player->player_position
  • $player->player_home_city
  • $player->player_home_state
  • $player->player_date_of_birth
  • $player->team_id
  • $player->player_weight
  • $player->player_height
  • $player->player_slug
  • $player->get_player_photo()

So now that we’ve gone over something we’ll be using here, let’s start building the player page, shall we? If you want to learn more about the Player class and the other classes, please visit the codex page on the Sports Bench website.

Building the Player Page

So creating the player page involves creating a new page template. It’s a simple concept in WordPress, but if you’re unfamiliar with it, you can read this, this and this tutorial on how to do that. Otherwise, let’s get started.

  1. So first off, create a new page template in your theme’s main directory. Name it page-player.php
  2. Next, copy the contents of your theme’s page.php file and paste it into this new page template file.
  3. At the top underneath the opening php tag, paste the following:
    Template Name: Player
  4. Look at the body of your new page template’s contents. First find the Loop. If you’re unfamiliar with the loop, look for a section that looks like if ( have_posts() ) : while( have_posts() ) : the_post();. Inside of that, look for a <main> or <article> tag and delete everything inside of that.
  5. Replace the now-deleted code with the following:
    				<?php if ( class_exists( 'Sports_Bench_Player' ) ) { ?>
    					<?php if ( get_query_var( 'player_slug' ) ) { ?>
    					<?php } else { ?>
    					<?php } ?>
    				<?php } ?>
    
  6. From here, let’s get the simple part out of the way first. Inside the else statement, place the following line of code:
    <?php echo sports_bench_show_team_player_select(); ?>
    This will show a dropdown of teams to pick players from if there’s no player slug in the url. For a live look at what this does, click here.
  7. With that out of the way, let’s get to the fun part. Inside of the if ( get_query_var( 'player_slug' ) ) statement, first add the following:
    				<? if ( get_query_var( 'player_slug' ) ) {
    				$player = new Sports_Bench_Player(get_query_var('player_slug'));
    				$team = new Sports_Bench_Team((int)$player->team_id);
    				} ?>
    
    				<div class="player-info">
    					<?php echo sports_bench_show_player_info( $player->player_id ); ?>
    				</div>
    

    This will display the player’s photo and his/her name, height, weight, position, age and hometown if those are entered. You might have to do some styling to get the section to match your theme’s style.

  8. Finally, below the code you just pasted, place the following lines of code:
    				<div id="player-stats" class="widget" style="border-top: 2px solid <?php echo $team->team_primary_color; ?>">
    					<h4 class="widgettitle"><?php echo __( 'Career Stats', 'sports-bench' ); ?></h4>
    					<?php echo sports_bench_get_season_stats( $player ); ?>
    				</div>
    

    This will show a table of the player’s career stats by season. And if you click on a season, you’ll see the game-by-game stats. And the best part, that functionality requires no code from you.

  9. Now, go create a new page. Title it “Players”. Then go down on the right side of the editor to the “Page Attributes” section and select “Player” from the page template dropdown.
  10. Next, go to the Sports Bench Settings page inside the Customizer. Then find the Player Page option and select the page you’ve just created. Then hit publish.
  11. After that, go to the permalinks page. This can be found under the Settings section in the admin. Don’t tough your permalinks, but hit save at the bottom. This will reset the necessary redirects to make the page work.
  12. Then navigate to that page. You should now see the dropdown. Pick a team and then click on a player. And now you should see his/her player page.

And that’s it! You’ve survived some intermediate coding and you’ve created a really cool player page that you can show off. You’re harnessing the power of Sports Bench. Confidence going up? Good. We’re going to take another step higher in the next section. But for now, admire your work.

Show How To

Adding Game Recaps and Previews

We are so close to the finish line. You’re doing great, but now we’ve reached our toughest challenge yet. However, with this as your guide, you’ll be done with it in no time.

This section deals with post templates. Introduced in WordPress 4.7, post templates work the same as page template, but obviously with post types and an extra line of code. This is also why WordPress 4.7 is required for this plugin.

This section will cover creating game preview and game recap post templates. We’ll start easy first with game previews.

Creating the Game Preview Template

There are two ways you can create game previews. The easiest is to use the “Game” shortcode. To do this, add a new post and then hit the “SB” at the top of the editor. Then select game and then the game you want to show. And that’s all you need. If you want to create a custom post template for previews, use the directions below.

  1. Like the player and team templates, create a new php file and name it page-game-preview.php. But now, copy the contents of your theme’s single.php file. And we’re also going to leave the loop untouched. Our focus is on the sidebar.
  2. Again, like the player team templates, add the following lines of code to right after the opening php tag. Note the extra line which helps WordPress realize that this is intended for posts and not pages.
    				Template Name: Game Preview
    				Template Post Type: post
    
  3. Now that that’s taken care of, let’s turn our attention to the sidebar. Again, locate where the get_sidebar function. If it’s wrapped in a div with a class of “sidebar” or “widgets” or something of the like, you have nothing to worry about. The lines of code we’ll write later on will go right before this function. Otherwise, locate your theme’s sidebar.php file. Copy the lines of code that control the primary sidebar and replace the get_sidebar function in the template with the copied code. It might look something like this:
    				<div id="sidebar1" class="sidebar>
    					<?php if ( is_active_sidebar( 'sidebar1' ) ) : ?>
    						<?php dynamic_sidebar( 'sidebar1' ); ?>
    					<?php endif; ?>
    				</div>
    

    Note: Your sidebar.php file probably won’t look exactly like this. This is more a guide. It should, however, at least look something like it if it’s up to WordPress standards.

  4. Now, right before either the code you just pasted or the get_sidebar functions, add in the following lines of code to add a game preview “widget”. This will show the teams’ records, names and logos as well as the date, time and location of the game. If the game is final, the score will show. And if the game has a recap, a link to the recap will show as well.
    				<?php echo sports_bench_show_game_preview_info(); ?>
    
  5. So that’s all of the coding we have to do for the preview template. Now let’s add a preview. To start, add a new page. Then type a preview into the main post editor.
  6. Once you are done, go the “Post Attributes” section on the right-hand side. Select “Game Preview” from the post template dropdown. next, find the custom fields for Sports Bench. It’ll be below the main editor somewhere, depending on what plugins you have installed. There, select “Preview” and then select which game this is a preview for.
  7. Now hit “Publish” and then hit “View Post”. And that’s it. You’ve created a really cool game preview post template that adds necessary info with minimal effort from you in the future. Congrats! Now let’s move on to game recaps.

Creating the Game Recap Template

There are two ways you can create game recap areas. The easiest is to use the game recap shortcode. To do this, add a new post and then hit the “SB” at the top of the editor. Then select “Game Recap” and then the game you want to show. And that’s all you need. If you want to create a custom post template for recaps, use the directions below.

  1. Like the game preview template, create a new php file and name it page-game-recap.php and copy the contents of your theme’s single.php file into the new template.
  2. Like the game preview template, add the following lines of code right after the opening php tag:
    				Template Name: Game Recap
    				Template Post Type: post
    
  3. Again, let’s turn our attention to where the get_sidebar function is located. If it’s inside a div with the class “sidebar” or “widgets” or the like, simply delete the function since we’re overriding the default sidebar here. Otherwise, go to the sidebar.php file and copy the div that contains the actual sidebar. You don’t need any inside that div, just the outer shell. Then paste that over the get_sidebar function in the recap template.
  4. Now, inside the sidebar container that was either already there or just pasted, place the following line of code:
    				<?php echo sports_bench_show_game_stats_info(); ?>
    
  5. So that’s all the coding you have to do. But let’s add a recap just to test it out. To start go add add a new post and put some text into the main text editor.
  6. Next, scroll down on the right-hand side and find the “Post Attributes” section. Select “Game Recap” as the post template.
  7. Then find the Sports Bench custom fields. This will be somewhere below the main post editor depending on what plugins you have on your site. There select “Recap” and then select the game the recap is for.
  8. Finally, hit publish and then view the post. Congrats! You’ve now created a recap template that will show off all sorts of information from the scoreline to the team stats to the individual stats. It looks awesome.

And that’s all the code you need to get started. The best part is now, when you create a preview or a recap for a game, the link to that post will automatically show up on the team page and where the game is located on the scoreboard. It adds that extra functionality that takes your site to the next level.

Show How To

Customizations

It is possible to make customization, both in the code in style. The recommended way is to make your own customization plugin so that your changes aren’t overwritten by an update. Here’s how to do that:

  1. Find the plugins directory on your web hosting and create a new directory inside of it. Call the new file ‘sports-bench-customizations’.
  2. Inside of the new directory, create a php file name sports-bench-customizations.php.
  3. Inside of the file, paste the following at the top:
    • <?php
                         /*
                         Plugin Name: Sports Bench Customizations
                         Plugin URI:
                         Description: A place to put customizations for the Sports Bench plugin
                         Version:     1.0
                         Author:
                         Author URI:
                         License:     GPL3
                         License URI: https://www.gnu.org/licenses/gpl-3.0.html
                         */
                         ?>
  4. Inside of this directory, you can include JavaScript, CSS, and other items and then call them from the php file. You can also create custom functions as well.
  5. Make sure to activate the plugin as you would any other plugin.
Show How To

Setting Up the Homepage

Setting up the homepage to run as it should is a fairly quick process.

  1. Navigate to the “Customize” page in the admin. Then click “Theme Settings”.
  2. Determine if you want to hide sticky posts in the slider and home page.
  3. Determine the category to show in the slider. The suggested practice is to create a “top story” category and use that.
  4. Determine the categories to show below the slider. Each category will show up as a tab, as well as a tab with all of the latest posts.

That’s it. The theme is all set up to run as you like.

Show How To

Creating a Longform Post

Creating a longform story is simple with WordPress 4.7 and the Sports Bench theme; however, for this to work, you must be using WordPress 4.7.

  • Create a post like you normally would. Typically, longform stories are over 1,000 words long, but any length will do for you.
  • Before hitting publish, scroll down to the “Post Attributes” box in the right sidebar of the page and select “Longform”.
  • Make sure you upload a large featured image as it will display across the top of the page.
Show How To