admin管理员组文章数量:1024885
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?
1 Answer
Reset to default 0There'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.
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?
1 Answer
Reset to default 0There'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.
本文标签: wp insert postwpinsertpost with data from graph api inside a plugin
版权声明:本文标题:wp insert post - wp_insert_post with data from graph api inside a plugin 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745496136a2153175.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论