Skip to main content

benecaster_feed_episode_data

Filter Free Since v1.0.0

Filters the data array for a single episode before it is rendered to RSS XML. This is the most granular per-episode customization point in the feed pipeline — modify any RSS field for a specific episode without touching the compiled XML string.

This filter fires once per episode, per tier, per feed compilation. For a show with many episodes across multiple tiers it can fire a large number of times per request on a cold cache, so keep callbacks lightweight. The complete set of data array keys and their corresponding RSS output:

| Key | Type | Maps to | |—|—|—| | `title` | string | `title` | | `description` | string | `description` and `itunes:summary` | | `enclosure_url` | string | `enclosure url` | | `enclosure_length` | int | `enclosure length` (bytes) | | `enclosure_type` | string | `enclosure type` MIME type | | `duration` | string | `itunes:duration` | | `guid` | string | `guid` | | `pub_date` | string | `pubDate` (RFC 2822) | | `link` | string | `link` — episode page URL | | `explicit` | bool | `itunes:explicit` | | `episode_number` | int\|null | `itunes:episode` | | `season_number` | int\|null | `itunes:season` | | `episode_type` | string | `itunes:episodeType` (`full`, `trailer`, `bonus`) | | `artwork_url` | string | `itunes:image href` | | `author` | string | `itunes:author` |

Parameters

Name Type Default Description
$data array Episode data array. See description for full key reference.
$episode_id int ID of the episode
$show_id int ID of the show

Returns: array

Examples

Override episode title from post meta

add_filter( 'benecaster_feed_episode_data', function( $data, $episode_id, $show_id ) {
    // Replace the RSS title with a custom SEO-optimized title stored in post meta.
    $seo_title = get_post_meta( $episode_id, '_benecaster_rss_seo_title', true );
    if ( $seo_title ) {
        $data['title'] = $seo_title;
    }
    return $data;
}, 10, 3 );

Append sponsor message to description

add_filter( 'benecaster_feed_episode_data', function( array $data, int $episode_id, int $show_id ): array {
    $sponsor = get_option( 'my_feed_sponsor_message' );
    if ( $sponsor ) {
        $data['description'] .= "\n\n" . $sponsor;
    }
    return $data;
}, 10, 3 );

Force explicit flag on all episodes

add_filter( 'benecaster_feed_episode_data', function( array $data, int $episode_id, int $show_id ): array {
    $data['explicit'] = true;
    return $data;
}, 10, 3 );

Notes

Prefer this filter over benecaster_feed_xml. Modifying structured data before serialization is safer and more maintainable than post-processing the XML string. Use benecaster_feed_xml only when injecting elements that have no corresponding key in this array.

The enclosure_url key is also accessible through the dedicated benecaster_feed_enclosure_url filter. Both affect the same value — use whichever is more readable for your use case.