benecaster_feed_enclosure_url
Filters the audio or video URL placed in the RSS `enclosure` tag for each episode. Use to route downloads through a tracking proxy (such as Podtrac or Chartable), append analytics parameters, or swap the URL entirely for a specific tier.
The same value is also accessible through [benecaster_feed_episode_data](/hooks/benecaster_feed_episode_data/) as the `enclosure_url` key — use this dedicated filter when you only need the URL and want to avoid receiving the full episode data array. The returned URL is placed directly in `enclosure url=”…”` and must always be a valid, non-empty URL.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$url |
string |
— | The enclosure URL |
$episode_id |
int |
— | ID of the episode |
$show_id |
int |
— | ID of the show |
$tier_slug |
string |
— | Tier slug for this feed compilation pass |
Returns:
string
Examples
Route enclosures through Podtrac
add_filter( 'benecaster_feed_enclosure_url', function ( string $url, int $episode_id, int $show_id, string $tier_slug ): string {
return 'https://dts.podtrac.com/redirect.mp3/' . ltrim( preg_replace( '#^https?://#', '', $url ), '/' );
}, 10, 4 );
Append UTM source parameter to track feed traffic
add_filter( 'benecaster_feed_enclosure_url', function ( string $url, int $episode_id, int $show_id, string $tier_slug ): string {
return add_query_arg( 'utm_source', 'rss_feed', $url );
}, 10, 4 );
Serve preview audio URL for free tier
add_filter( 'benecaster_feed_enclosure_url', function ( string $url, int $episode_id, int $show_id, string $tier_slug ): string {
if ( 'free' === $tier_slug ) {
$preview_url = get_post_meta( $episode_id, '_preview_audio_url', true );
if ( $preview_url ) {
return $preview_url;
}
}
return $url;
}, 10, 4 );
Notes
The returned URL is placed directly in enclosure url="...". An invalid or empty return value produces a malformed feed item that podcast apps may reject. This is a Free filter — it fires regardless of license status.