How to delete transients written by fetch_feed()?

This data should be automatically deleted after 12 hours, that’s the default feed cache TTL.

So this kind of house cleaning, for data added by the WordPress transients API, might be unnecessary.

But let’s check out what kind of data is stored.

If you take for example the feed for your current question:

http://wordpress.stackexchange.com/feeds/question/172444

and fetch it with:

$feed = fetch_feed( 'http://wordpress.stackexchange.com/feeds/question/172444' );

then you would get 4 rows in the wp_options table:

  1. _transient_feed_mod_89d724e05be3479dcbee0fd481470c97
  2. _transient_timeout_feed_mod_89d724e05be3479dcbee0fd481470c97
  3. _transient_feed_89d724e05be3479dcbee0fd481470c97
  4. _transient_timeout_feed_89d724e05be3479dcbee0fd481

The _transient_timeout_* rows are automatically added by WordPress to know when to delete the transients.

Notice that:

echo $md5_of_feed_url = md5( 'http://wordpress.stackexchange.com/feeds/question/172444' );

is

89d724e05be3479dcbee0fd481470c97

So you would need to know the md5 of the feed url, to remove this data with the delete_transient() function:

delete_transient( 'feed_'     . $md5_of_feed_url ); 
delete_transient( 'feed_mod_' . $md5_of_feed_url );