{"id":6338900,"date":"2015-07-17T19:14:39","date_gmt":"2015-07-17T19:14:39","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/efficiently-updating-many-posts\/"},"modified":"2016-08-30T15:51:35","modified_gmt":"2016-08-30T15:51:35","slug":"efficiently-updating-many-posts","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/efficiently-updating-many-posts\/","title":{"rendered":"Efficiently updating many posts"},"content":{"rendered":"<p>I&#8217;m attempting to create a plugin that will perform mass post updates. It works by retrieving the list of posts to be processed, changing post_content in some way, then calling wp_udpate_post on each to save the changes back to the database.  As a way of providing an undo if necessary, I like the fact that a new revision is created if they haven&#8217;t been disabled. To avoid PHP timeouts, I&#8217;m batching the work with ajax, so each request causes 10 posts to be updated before requesting the next 10, until all have been updated.<\/p>\n<p>The problem I&#8217;m finding is that all those calls to wp_update_post are both slow and resource intensive. I&#8217;ve run on a variety of hosted servers and while some hold up better than others, I&#8217;d certainly like to improve the performance.<\/p>\n<p>Any suggestions for a more efficient way of updating the posts (and still creating revisions)?<\/p>\n","protected":false},"template":"","class_list":["post-6338900","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6338900","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6338900\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=6338900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}