• 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)
  • 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

    (@jbarker147)

    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();

    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.