Bypass fetch_feed cache

SimplePie does not necessarily use the exact feed URL that was passed to fetch_feed() – see SimplePie::get_cache_filename(), but yes, WordPress adds the feed_ prefix to the transient key.

So you can instead try using the wp_feed_options hook to get the correct transient key and then delete the existing transient.

$bypass = $this->bypass;

add_action(
    'wp_feed_options',
    function ( $feed ) use ( &$bypass ) {
        if ( $bypass ) {
            $cache_key = 'feed_' . $feed->get_cache_filename( $feed->feed_url );
            delete_transient( $cache_key );
            $bypass = false; // transient deleted, so reset this to the default
        }
    }
);

$feedData = fetch_feed( $this->feedUrl );

If you do not need to update the cached data, i.e. you just wanted to bypass reading from the cache, then you could simply use function ( $feed ) use ( &$bypass ) { $feed->cache = ! $bypass; }.

tech