Latest Posts

How to Delete Transients in WordPress

WordPress plugins and themes can store a lot of temporary data known as transients. By default these transients are stored in the wp_options table and can accumulate rather quickly. Due to an idiosyncrasy in WordPress core, expired transients are only removed from the database if access to them is attempted, if no access to them is made then the transients stay in the wp_options table. This tutorial will show you how to delete expired transients using WP-CLI from wp_options or your external object cache and automate the deletion of these transients ever day using a cronjob.

Delete the value of a network|site transient. On single site, this is is a specially-named cache key. On multisite, this is a global cache (instead of local to the site).

In fact, WordPress theme and plugin developers make use of these transients to store timely data in order to increase the speed and efficiency. For instance, a plugin or theme may want to check for updates every 24 hours. Once checked, this data is stored as a transient so that the plugin or theme doesn’t make another request everytime the page loads.

The good thing is that this transient data will automatically expire at set periods of time. However, sometimes these transients may quickly pile up and you may not see some changes you made right away. Moreover, the piled up transients may also increase the database size.

WordPress Transients API offers a simple and standardized way of storing cached data in the database. It is also possible to use APC or memcached to store the transients, thus increasing the overall performance of a WordPress site. When we do so, the existing transients are not removed from the database. The following commands help to do just that…

DELETE FROM `wp_options` WHERE `option_name` LIKE ('_transient_%');
DELETE FROM `wp_options` WHERE `option_name` LIKE ('_site_transient_%');

To increase performance, WordPress plugins may use the transients API to store some data in the database. While this does increase performance, some old data can be left by disabled or removed plugins that can adversely affect performance. In this article, we will show you how to remove expired transients from your WordPress database.

Latest Posts

Don't Miss