How to import posts correctly?

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.

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

1 Answer 1

Reset to default 0

You 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!

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

相关推荐

  • How to import posts correctly?

    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.

    1天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信