最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp insert post - wp_insert_post with data from graph api inside a plugin

programmeradmin2浏览0评论

I'm creating a plugin that creates a post in a CPT for every Facebook page post (using fb graph api). When should I fire the function that gets the data? using an action? Also if I understood the docs correctly, the wp_insert_post takes ID as an argument, which if doesn't exist, sets the newly created post id to that value?

I'm creating a plugin that creates a post in a CPT for every Facebook page post (using fb graph api). When should I fire the function that gets the data? using an action? Also if I understood the docs correctly, the wp_insert_post takes ID as an argument, which if doesn't exist, sets the newly created post id to that value?

Share Improve this question edited May 14, 2019 at 12:55 cjbj 15k16 gold badges42 silver badges89 bronze badges asked May 14, 2019 at 12:25 Silvester VellaSilvester Vella 155 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

There's no way to get notifications from Facebook for a new post. You have to check by hand. Just set a transient with the desired expire time for the data so you don't make a request on each reload, maybe check hourly for new data or every 30 mins, up to you.

As for your second question, read the docs:

https://developer.wordpress/reference/functions/wp_insert_post/

It automatically assigns an ID unless provided by you (which is auto-incremented by the system) but you still need to provide more things in the array, even if some are default, you might not want it like that.

发布评论

评论列表(0)

  1. 暂无评论