Support

Account

Home Forums General Issues Updating field in two places

Solving

Updating field in two places

  • We are working on a project that has leaderboards for a series of games and players. The players will participate in several games over the summer. What we would like to do is create a field in the players custom post type and then on the single game page update that players score based on how many points they received in the given game. Basically we want to update a field in two places in the admin. Has anyone attempted something similar? Any insights would be highly appreciated!

  • Are you trying to total the points for each game that a player scored points and then post the player’s total points on a single page?

  • This is somewhat involved, but assuming you have a player post for every player and a post for tracking the scores for each game, I would do the following:

    Create a taxonomy for the games. Ex.: Summer Tournament 2018.
    Create a field group with a number field for each game. So, if there are 16 games, there will be 16 boxes. Set your rules to have these appear where the Post Type is Player (or whatever your CPT is for players).

    Create a repeater with two fields: a post object field (players) and a number field. This should appear in whatever post or page you are using to keep track of a given game. The post object field will link the game to the player. Set your rules to appear where Post Type is (whatever post you are tracking the scores for each game) and the Taxonomy is (whatever you call your tournament). This is where you will track the scores for each player for a given game.

    Create a post for each of the summer games.

    The update field function will involve:
    Running a query to get the post ids for all the summer games.
    An outside loop of all the summer games, and an inside loop of the repeater with the scores for each game.
    Now you can grab the post id of the player and update the box corresponding to the game in the players profile.

    Now you can loop through each player and show their points on a separate page.

  • Here is a picture of a repeater that I use for my site:

  • Instead of adding 16 individual boxes, I would put the boxes that are going to hold the scores inside the player post in a repeater. You can set the minimum and maximum rows to the number of games in the tournament.

    This is a sample:

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.