Is it possible to create + update a CPT after a post have been created sequentially in the same flow?
For example:
First: I do a wp_insert_post($my_first_cpt) (with some data, and it's executed on save_post hook)
Second: wp_update_post($my_second_cpt) (with DATA from $my_first_cpt, for example a random seed) and show be executed inmediately after
So essentially $my_first_cpt has to be created and stored and inmediately afterwards, something has to fire to get data from $my_first_post and update $my_second_post
Is this possible? I've tried to put one after another and it doesn't simply work.
Is it possible to create + update a CPT after a post have been created sequentially in the same flow?
For example:
First: I do a wp_insert_post($my_first_cpt) (with some data, and it's executed on save_post hook)
Second: wp_update_post($my_second_cpt) (with DATA from $my_first_cpt, for example a random seed) and show be executed inmediately after
So essentially $my_first_cpt has to be created and stored and inmediately afterwards, something has to fire to get data from $my_first_post and update $my_second_post
Is this possible? I've tried to put one after another and it doesn't simply work.
Share Improve this question asked Sep 21, 2019 at 17:57 SirLouenSirLouen 857 bronze badges1 Answer
Reset to default 0I've found a solution, which I'm not liking much, but it works
Essentially what I do is create two hooks to save_post (in this case this is the action that launches this script) with different priorities for example 10 and 20 In the priority 10 I put the wp_insert_post And in the priority 20 I put the wp_update_post
It works, but is doesn't seem to be the best solution...