Skip to main content

benecaster_episode_description_output

Filter Free Since v1.0.0

Filters the final rendered HTML output of the [benecaster_episode_description] shortcode before it is returned. The $description parameter is the description string after benecaster_episode_description has already run, giving you both the filtered source text and the compiled HTML.

Use this filter to wrap the output in a custom container, add schema markup, inject a collapsible behavior class, or replace the markup entirely. If you only need to modify the underlying description text rather than the HTML wrapper, use benecaster_episode_description instead.

Parameters

Name Type Default Description
$html string Rendered HTML output
$description string The filtered description string passed to the renderer
$atts array Resolved shortcode attributes including episode_id and show_id

Returns: string

Examples

Collapsible wrapper for long descriptions

add_filter( 'benecaster_episode_description_output', function( $html, $description, $atts ) {
    // Add a "Read more" toggle for descriptions longer than 300 characters.
    if ( mb_strlen( wp_strip_all_tags( $description ) ) > 300 ) {
        return '<div class="episode-description episode-description--collapsible">' . $html . '</div>';
    }
    return $html;
}, 10, 3 );

Wrap output in custom div

add_filter( 'benecaster_episode_description_output', function( string $html, string $description, array $atts ): string {
    return '<div class="episode-description-wrapper">' . $html . '</div>';
}, 10, 3 );

Notes

To modify the description string before HTML is generated, use benecaster_episode_description instead. Both filters can be used together — benecaster_episode_description fires first, and its output becomes the $description argument passed to this filter.

Affects

  • [benecaster_episode_description] shortcode