Title: Custom Code
Last modified: February 27, 2023

---

# Custom Code

 *  Resolved [sameeralam](https://wordpress.org/support/users/sameeralam/)
 * (@sameeralam)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/custom-code-17/)
 * From the shortcodes, for ex, [https://gnbl.ca/player/arsalaan-abdullah/](https://gnbl.ca/player/arsalaan-abdullah/)[
   player_statistics 2770] this would get me the player stats for all the games.
 * Is there a way to get only specific values or fields? How or where would I have
   to create custom code to be able to use all this excellent data created and run
   my own enhanced analytics, etc.

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Thread Starter [sameeralam](https://wordpress.org/support/users/sameeralam/)
 * (@sameeralam)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/custom-code-17/#post-16514326)
 * In addition to this, is there a way I can post player splits ( add a new tab 
   like how we can move stats, profile, games in a new tab on player page ), create
   a splits category which might show the players last 5 game averages, or last 
   30 day averages, their home average vs away, how they play with a certain teammate
   etc.
 * I am happy to code all this myself of course, I just need some direction in terms
   of if it is possible and how I could access the data appropriately.
 *  Plugin Contributor [Savvas](https://wordpress.org/support/users/savvasha/)
 * (@savvasha)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/custom-code-17/#post-16544582)
 * Hi there [@sameeralam](https://wordpress.org/support/users/sameeralam/) ,
 * All your player stats can be called using the [SP_Player](https://github.com/ThemeBoy/SportsPress/blob/master/includes/class-sp-player.php)
   Class. You can give a look at [player-statistics](https://github.com/ThemeBoy/SportsPress/blob/master/templates/player-statistics.php)
   template for example on how you can show your data.
 * Thanks,
   Savvas
 *  Thread Starter [sameeralam](https://wordpress.org/support/users/sameeralam/)
 * (@sameeralam)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/custom-code-17/#post-16548408)
 * Thanks Savvas! Can I call this class from the custom code portion in sportspress.
   Or Will I have to modify the plugin code directly? (Sorry, I’m a bit new to wordpress
   plugins) If you can guide me a bit further, that would be appreciated.
 * For ex: [https://gnbl.ca/statistics-2022-2023/](https://gnbl.ca/statistics-2022-2023/),
   to get the top 5 player names who have the highest PPG. Is it easy to share how
   to get this data? If I can see this example, then I should be able to figure 
   out the rest of the things I want to gather.
 * If it is complicated to explain, then no worries.
 *  Plugin Contributor [Savvas](https://wordpress.org/support/users/savvasha/)
 * (@savvasha)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/custom-code-17/#post-16551282)
 * Hi there [@sameeralam](https://wordpress.org/support/users/sameeralam/) ,
 * To call any class you need just to… call it. No need for editing the core file
   or anything.
 * For example at your custom code you can just use the following to get all your
   Player’s data for a specific League:
 *     ```wp-block-code
       //$id is your player's ID
       //$league_id is the the League ID for which you need the data.
       $player = new SP_Player( $id );
       $player_data = $player->data( $league_id );
       ```
   
 * Thanks,
   Savvas
 *  Thread Starter [sameeralam](https://wordpress.org/support/users/sameeralam/)
 * (@sameeralam)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/custom-code-17/#post-16556664)
 * Thanks Savvas, so I get the class to call and I can create the code as needed
   to suit my requirement. But where exactly can I enter this code? Directly in 
   a wordpress page doesnt work, neither is there an option in any of the sportspress
   configure pages.
 * The only place I see where there is code are in the plugin files (which is why
   I initially was wondering if I need to create a new plugin or modify existing
   code).
 * I hope the question is clear – please let me know where I would be able to enter
   my new code/ call the SP_Player class.
 *  Plugin Contributor [Savvas](https://wordpress.org/support/users/savvasha/)
 * (@savvasha)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/custom-code-17/#post-16557186)
 * Hi [@sameeralam](https://wordpress.org/support/users/sameeralam/) ,
 * At the below links you will find all the info you need 🙂
 * [https://managewp.com/blog/add-code-snippets-to-wordpress](https://managewp.com/blog/add-code-snippets-to-wordpress)
   
   [https://www.wpbeginner.com/beginners-guide/beginners-guide-to-pasting-snippets-from-the-web-into-wordpress/](https://www.wpbeginner.com/beginners-guide/beginners-guide-to-pasting-snippets-from-the-web-into-wordpress/)
 * Thanks,
   Savvas

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Custom Code’ is closed to new replies.

 * ![](https://ps.w.org/sportspress/assets/icon-256x256.png?rev=1252005)
 * [SportsPress - Sports Club & League Manager](https://wordpress.org/plugins/sportspress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/sportspress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/sportspress/)
 * [Active Topics](https://wordpress.org/support/plugin/sportspress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sportspress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sportspress/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Savvas](https://wordpress.org/support/users/savvasha/)
 * Last activity: [3 years, 2 months ago](https://wordpress.org/support/topic/custom-code-17/#post-16557186)
 * Status: resolved