I’ve seen an article saying that in order to delete WordPress feed caches, the following code would work.
global $wpdb;
$wpdb->query( "DELETE FROM `wp_options` WHERE `option_name` LIKE ('_transient%_feed_%')" );
So how do I apply this to my own transient caches?
If I save data like,
set_transient('mytransient_oneminutecache', $data1, 60);
set_transient('mytransient_onehourcache', $data2, 60 * 60);
set_transient('mytransient_12hourcache', $data3, 60 * 60 * 12);
Then does this work?
global $wpdb;
$wpdb->query( "DELETE FROM `wp_options` WHERE `option_name` LIKE ('_transient%mytransient_%')" );
Or should it be
global $wpdb;
$wpdb->query( "DELETE FROM `wp_options` WHERE `option_name` LIKE ('_transient%_mytransient_%')" );
?
I’m not used to view data base tables so if you can tell if it works or not or how to view inside the option table, it would be appreciated.
Okay, I think I got it.
First I ran this
Next opened, http://[site address]/wp-admin/options.php
then found these are saved:
So after that, I ran this and they were gone!
is probably better because an _ is a single-character wildcard so needs escaping .