New answers tagged


This one below is actually better I believe:


While it is good that you found the specific problem in your setup, the general answer is that you are doing it wrong. Every time that you are doing anything which requires many DB operations you are risking running out of memory, out of bandwidth to the DB server, or out of time. It may get very tricky as something that might work on one server will fail ...


It turns out that it was due to Query Monitor, a plugin that records info about each query. Every time update_post_meta ran, Query Monitor would store some data about the query, which eventually added up to be more than the server could handle. Running my example code on a default theme like Twenty Nineteen with no other plugins enabled results in the ...


You want the Transients API: get_transient and set_transient (and get/set_site_transient). These store values in the wp_options table with a namespace and expiry date, so they do persist through page reloads. (As does anything stored in the database, unless you explicitly create per-connection temporary tables.)

Top 50 recent answers are included