custom post types - Create and Update 2 CPT sequentially

Is it possible to create + update a CPT after a post have been created sequentially in the same flow?For example: First:

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

I'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...

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745140367a4613401.html

相关推荐

  • custom post types - Create and Update 2 CPT sequentially

    Is it possible to create + update a CPT after a post have been created sequentially in the same flow?For example: First:

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信