Skip to main content

benecaster_rss_extra_item_tags

Filter Free

Adds elements to each episode’s <item> that benecaster_feed_episode_data has no key for — a sponsor line, a chapters file from another service, a custom CMS field. Return an array of tags; Benecaster writes and escapes the XML, so a mistake here cannot break the feed. They render last, just before </item>, and benecaster_feed_item_xml sees them.

Same shape and rules as benecaster_rss_extra_channel_tags: 'prefix:name' => 'text', or [ 'value' => …, 'attributes' => [ … ] ], an empty value self-closes, a list under one name emits one element per entry, anything unusable is dropped, and a custom prefix must be declared through benecaster_feed_namespaces.

Fires once per episode, per tier, per feed compilation — keep callbacks lightweight.

Parameters

Name Type Default Description
$tags array — Tags to add, keyed by element name. Empty by default.
$episode_id int — ID of the episode
$show_id int — ID of the show
$tier_slug string — Tier slug for this feed compilation pass (`public` for the public feed)

Returns: array

Example

add_filter( 'benecaster_rss_extra_item_tags', function ( array $tags, int $episode_id ): array {
    $url = (string) get_post_meta( $episode_id, '_my_chapters_json_url', true );
    if ( '' !== $url ) {
        $tags['podcast:chapters'] = [
            'value'      => '',
            'attributes' => [ 'url' => $url, 'type' => 'application/json+chapters' ],
        ];
    }
    return $tags;
}, 10, 2 );

Notes

The filter receives an array, not a raw XML string — the shape a caller cannot use to produce an unparseable feed.

Need this built rather than just documented? See our services →