admin管理员组文章数量:1405916
There are 2 tasks, there is a site X on which there are 1,500 posts, each entry has a title, a thumbnail and 3 metadata. You need to export these entries to other sites. Those. first you need to write a microapi that will generate json for example, and on the side of other sites (where you need to parse these same entries) a plugin that will receive the same json in the url and create entries. The option of exporting xml and importing to other sites is not suitable, you just need to make a script. I made json generation, it remains to do import of records on the basis of json. The main question is how to make imports. so that it works stably, because running foreach from 1500 wp_insert_post is not a good option, right? Please tell me in which direction to look at the implementation of such a task.
Thanks!
There are 2 tasks, there is a site X on which there are 1,500 posts, each entry has a title, a thumbnail and 3 metadata. You need to export these entries to other sites. Those. first you need to write a microapi that will generate json for example, and on the side of other sites (where you need to parse these same entries) a plugin that will receive the same json in the url and create entries. The option of exporting xml and importing to other sites is not suitable, you just need to make a script. I made json generation, it remains to do import of records on the basis of json. The main question is how to make imports. so that it works stably, because running foreach from 1500 wp_insert_post is not a good option, right? Please tell me in which direction to look at the implementation of such a task.
Thanks!
Share Improve this question edited Dec 3, 2019 at 12:40 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Dec 3, 2019 at 7:31 user2792900user2792900 32 bronze badges1 Answer
Reset to default 0You could always give it a try, i've imported around 300 posts at the same time before so, it shouldn't be that big of a deal. You could try the following methods if you have problems with importing them all at once.
- Try re-defining WP_MEMORY_LIMIT and increase it to i.e. 1024MB
- Try increasing the max_execution_time (Check this link for more information)
- Try to split/chunk the array in a few different arrays and add a
usleep
after every iteration
Please note that within the foreach
$id = wp_insert_post()
will set $id
to the ID
of the Post/Page that is being added. If desired you can use this variable to add i.e. meta_values, thumbnails, etc.
Good luck!
本文标签: How to import posts correctly
版权声明:本文标题:How to import posts correctly? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744944578a2633695.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论