Home › Forums › General Issues › Updating field in two places › Reply To: Updating field in two places
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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.