Skip to main content

Inject Additional Podcasting 2.0 Channel Tags from an Add-on

Free Intermediate

Podcasting 2.0 is a set of extra tags that modern podcast apps understand — a funding link, a lock against unauthorised copying, a licence declaration. Benecaster fills in the show-level ones from the show’s own settings and writes them into the feed.

benecaster_feed_podcast_channel_tags hands an add-on that set just before it becomes XML, so it can add tags of its own, change what Benecaster worked out, or take something out. The namespace declaration the tags need is added for you whenever at least one of them survives to the output, so you never have to think about it.

If all you want is different wording on the funding link, benecaster_feed_podcast_funding_label changes that one label and leaves everything else alone.

Code

<?php
add_filter( 'benecaster_feed_podcast_channel_tags', function ( array $tags, int $show_id ): array {
    // Add a podcast index ownership verification string.
    $tags['txt'][] = [
        'purpose' => 'verify',
        'value'   => get_post_meta( $show_id, '_my_addon_podindex_claim', true ) ?: '',
    ];
    // Remove empty claims.
    $tags['txt'] = array_filter( $tags['txt'], fn( $t ) => $t['value'] !== '' );

    return $tags;
}, 10, 2 );

// Override the funding label for shows with a custom campaign label stored in meta.
add_filter( 'benecaster_feed_podcast_funding_label', function ( string $label, int $show_id ): string {
    $custom = (string) get_post_meta( $show_id, '_my_addon_funding_cta', true );
    return $custom !== '' ? $custom : $label;
}, 10, 2 );

View on GitHub →

Hooks Used

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