Title: Games Tally
Last modified: July 13, 2019

---

# Games Tally

 *  [jbarker147](https://wordpress.org/support/users/jbarker147/)
 * (@jbarker147)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/games-tally/)
 * Hi all
 * I’m looking to create a counter/tally to show the total number of games played
   in the snooker league over all the seasons. I don’t need to do it for each team,
   I need an overall total.
 * For example, I’ve got 10 events/matches, and a total of 72 games/frames played.
   How can I get to the result of 72? I was thinking of looping through the posts
   and for each post add the home result and away result, but I can’t seem to get
   the query to work 🙁
 * Does anybody know how this can be done?
    Many thanks in advance.

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

 *  [Roch](https://wordpress.org/support/users/rochesterj/)
 * (@rochesterj)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/games-tally/#post-11732905)
 * Hi!
 * Thanks for reaching out!
 * Unfortunately, we don’t have an option for this. Indeed you’ll probably need 
   a custom query if this isn’t as simple as multiplying the number of events by
   a fixed number.
 * If you do have this information somewhere (your league tables, for example), 
   it’s probably easier to display the entire table and use a simple JS code to 
   retrieve values from that table and remove it (so users won’t see what is going
   on).
 * Thanks!
 *  Thread Starter [jbarker147](https://wordpress.org/support/users/jbarker147/)
 * (@jbarker147)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/games-tally/#post-11733894)
 * Hi Roch,
    Thanks for the reply!
 * The code I’ve got is below – it loops through each published event and adds the
   scores together – the only thing missing is how to reference the home team score
   and the away team score for the post. I was hoping it was something as simple
   as sp_result_home and sp_result_away but it doesn’t look like that’s possible.
   There must be a way to query them, because they show on the event result, but
   I can’t seem to find how to do it.
 * Any advice?
 *     ```
       $args = array(
          'post_type' => 'sp_event',
          'status' => 'publish',
          'posts_per_page'=>'-1'
       );
   
       $query_frames = new WP_Query($args);
   
       $framescount = 0;
   
       if( $query_frames->have_posts() ) :
          while( $query_frames->have_posts() ) : $query_frames->the_post();
   
          $homescore = ???;
          $awayscore = ???;
   
          $framescount = $framescount + $homescore + $awayscore;
   
          endwhile;
       endif;
   
       echo $framescount;
   
       wp_reset_query();
       ```
   
 *  [Roch](https://wordpress.org/support/users/rochesterj/)
 * (@rochesterj)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/games-tally/#post-11736347)
 * Hi!
 * Thanks for your reply.
 * Unfortunately, this kind of customization is beyond the scope of our support.
   But I’ll leave this open in case another user or dev has any input on this.
 * Thanks!

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

The topic ‘Games Tally’ 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/)

 * 3 replies
 * 2 participants
 * Last reply from: [Roch](https://wordpress.org/support/users/rochesterj/)
 * Last activity: [6 years, 10 months ago](https://wordpress.org/support/topic/games-tally/#post-11736347)
 * Status: not a support question