Skip to main content

benecaster_episode_description

Filter Free

Filters the raw episode description string before it is returned or rendered. Fires in both the [benecaster_episode_description] shortcode and the benecaster_get_episode_description() template function.

This filter operates on the raw text string before any HTML is generated. If you want to modify the final rendered HTML output of the shortcode rather than the underlying text, use benecaster_episode_description_output instead.

Parameters

Name Type Default Description
$description string — The episode's raw description text
$episode_id int — ID of the resolved episode

Returns: string

Examples

Prepend active sponsor message

add_filter( 'benecaster_episode_description', function( $description, $episode_id ) {
    // Prepend a sponsor message to all episode descriptions when a campaign is active.
    $sponsor_note = get_option( 'my_plugin_sponsor_note' );
    if ( $sponsor_note ) {
        return $sponsor_note . "\n\n" . $description;
    }
    return $description;
}, 10, 2 );

Append standard disclaimer

add_filter( 'benecaster_episode_description', function( string $description, int $episode_id ): string {
    // Append a standard disclaimer to all episode descriptions
    return $description . ' ' . get_option( 'my_podcast_disclaimer', '' );
}, 10, 2 );

Notes

This filter fires on the raw string before HTML is generated. To modify the final rendered HTML output of the [benecaster_episode_description] shortcode, use benecaster_episode_description_output instead.

Affects

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