Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I efficiently perform a batch processing action on almost 8,000 WordPress posts?

Tags:

wordpress

I have written a WordPress plugin that analyzes a post and extracts some data from the body on save (using the save_post action).

My installation has almost 8,000 posts, and I need to perform this retroactively on every single post. So, I need a batch job of some kind that will iterate every post and perform this operation without timing out.

There are a number of ways to architect this, but is there a commonly accepted way of doing this?

like image 397
Deane Avatar asked Aug 05 '26 02:08

Deane


1 Answers

Ashley Rich from Delicious Brains created a Background Processing class that was designed to solve this exact problem. You can find the source code here. You can also find an example of it being used inside the WooCommerce plugin

like image 100
Santiago Garza Avatar answered Aug 07 '26 14:08

Santiago Garza



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!