Skip to main content

Inject Additional Podcasting 2.0 Channel Tags from an Add-on

Free Intermediate Since v1.0.0

Fires before channel-level podcast: namespace tags are rendered to XML. The initial array is pre-populated from show meta (guid, locked, funding, block, txt, license). Add-ons receive the populated array and may add, override, or remove any entry. The xmlns:podcast declaration is automatically added when at least one podcast: tag is present in the rendered output.

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