Delete All Transients in WordPress

This is a quick and simple way to delete all transients in WordPress. Add this to your functions.php file. Run it once by visiting the site in your browser. Then, to stop it from running, you can comment out the last line until you need to use it again.

(See this instead to delete only expired transients.)

(See the comment below for an easier WP-CLI solution.)

PHP

/**
* Delete ALL transients from the wpdb
*/
function isa_delete_all_transients() {

	global $wpdb;

	$sql = 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE "_transient_%"';
	$wpdb->query($sql);

}
add_action( 'init', 'isa_delete_all_transients' );

See more:

By

We've One Response

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this:

[code]

YOUR CODE HERE 

[/code]