How to purge all transient caches?

Is there an easy way to delete all transient caches? A plugin maybe? Or like in drupal “drush cc all”?

Related posts

3 comments

  1. 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.

  2. 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()
    

Comments are closed.