Skip to main content

benecaster_show_description

Filter Free Since v1.0.0

Filters the raw show description string before it is returned or rendered. This filter fires in both the [benecaster_show_description] shortcode and the benecaster_get_show_description() template function, so it applies to all consumers of the show description — including RSS feed channel tags.

The $type parameter identifies which description is being retrieved: 'short' corresponds to the short description stored in show post meta and used as the RSS channel description and itunes:summary; 'full' corresponds to the post content. Because the short description feeds the RSS channel tags, changes here affect both the RSS feed and any shortcode placements simultaneously. To filter only the final rendered HTML from the shortcode without touching the raw string or the RSS feed, use benecaster_show_description_output instead.

Parameters

Name Type Default Description
$description string Raw description string from post meta (short) or post_content (full)
$show_id int ID of the show
$type string Which description was resolved: 'short' or 'full'

Returns: string

Examples

Truncate short description to 160 chars

add_filter( 'benecaster_show_description', function( $description, $show_id, $type ) {
    // Truncate the short description to 160 characters for meta-tag use.
    if ( 'short' === $type && mb_strlen( $description ) > 160 ) {
        return mb_substr( $description, 0, 157 ) . '…';
    }
    return $description;
}, 10, 3 );

Append promotional suffix to short description

add_filter( 'benecaster_show_description', function ( string $description, int $show_id, string $type ): string {
    if ( 'short' === $type ) {
        $description = rtrim( $description, '.' ) . '. New episodes every Tuesday.';
    }
    return $description;
}, 10, 3 );

Override description for a specific show

add_filter( 'benecaster_show_description', function ( string $description, int $show_id, string $type ): string {
    if ( 123 === $show_id && 'short' === $type ) {
        return 'Your weekly deep-dive into independent podcasting. Subscribe free.';
    }
    return $description;
}, 10, 3 );

Notes

Modifying the short description ($type = 'short') also changes the RSS channel description and itunes:summary tags. To filter only the shortcode HTML output without affecting the raw string or the RSS feed, use benecaster_show_description_output instead.

Affects

  • [benecaster_show_description] shortcode
  • benecaster_get_show_description() function