Is there an easy way to delete all transient caches? A plugin maybe? Or like in drupal "drush cc all"?
3 Answers
Not tested, but if you need a quick and dirty way, you could put a script like this in your WordPress folder and call it each time:
define( 'WP_USE_THEMES', false );
require('wp-blog-header.php');
global $wpdb;
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '%\_transient\_%'" );
Not to be used on a production server.
If you can access your database through phpmyadmin or something equivalent, I would recommand you to use this :
DELETE a, b FROM wp_options a, wp_options b WHERE a.option_name LIKE '_transient_%'
AND a.option_name
NOT LIKE '_transient_timeout_%'
AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, CHAR_LENGTH('_transient_') + 1 ) ) AND b.option_value < UNIX_TIMESTAMP()
-
-
@NamGVU it's a little bit complicated but basically we do not want to mess up with transients used by WP core itself and those which are actually running. We want only expired transients.– JMauJul 11, 2015 at 17:14