WP update posts using info from another post and math operations in it [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed yesterday. Improve this question I have WP site of Mafia game. I have custom post "Game", where I put info about players and their achievements in game. Also I have custom post "Player", where I show all data from all games and in single-player.php I do my math (summarising data). So I need this changed data from all games from post "Game" put into post "Player", to make page Top players (I need to calculate which player is the best). The difficult is that in post "Game" I have ACF repeater for the data of the game, it means that I can't just call wp_query at page "Top players" of post "Game", because all math calculates at single-player.php. I found update_post(), but it forces me to open every players page to update data for this player. Question: How is it possible to make it more automative? I thought about writing own function in functions.php to update post data when new game has been published, so all data will be updated automatically, but have no clue where I need to start. I began from simple - just made a new ACF field for post "Player", where and while I update single-player.php at front I can update data at that field. update_field('player_stats_games_total',$game_count_of_player); This is not a beautiful solution. I wish someone clever can solve this puzzle. UPD: added post update on "Top player" page, but still doesn't work. $player_post_update = [ 'ID' => get_the_ID(), 'meta_input' => [ 'player_stats_games_total' => $game_count_of_player, ], ]; wp_update_post( wp_slash($player_post_update) ); By this action, I'm trying to update all "Player" post data.

Comment (0)

You’ll be in good company