Skip to main content

benecaster_rss_link_output

Filter Free

Filters the final rendered output of the [benecaster_rss_link] shortcode before it is returned to the page. Depending on the style attribute, $html may be an a tag, an SVG icon, or a bare URL string — the filter fires in all three cases.

This is a Free filter. Use $feed_url when you need the original unmodified feed URL regardless of how $html has been transformed by previous filter callbacks. The $atts array contains the resolved shortcode attributes including show_id, style, label, and icon_size.

Parameters

Name Type Default Description
$html string Rendered output — an `a` tag, an SVG icon, or a bare URL depending on the style attribute
$feed_url string The show's public RSS feed URL
$atts array Resolved shortcode attributes including show_id, style, label, and icon_size

Returns: string

Examples

Wrap in click-analytics tracking span

add_filter( 'benecaster_rss_link_output', function( $html, $feed_url, $atts ) {
    // Wrap the RSS link in a tracking span for click analytics.
    return '<span class="rss-link-wrapper" data-feed="' . esc_attr( $feed_url ) . '">' . $html . '</span>';
}, 10, 3 );

Add tooltip to anchor element

add_filter( 'benecaster_rss_link_output', function ( string $html, string $feed_url, array $atts ): string {
    return str_replace( '<a ', '<a title="Subscribe in your podcast app" ', $html );
}, 10, 3 );

Append UTM parameter for bare URL output

add_filter( 'benecaster_rss_link_output', function ( string $html, string $feed_url, array $atts ): string {
    if ( filter_var( $html, FILTER_VALIDATE_URL ) ) {
        return add_query_arg( 'utm_source', 'website', $html );
    }
    return $html;
}, 10, 3 );

Notes

When the shortcode is used with style="url" to retrieve the raw feed URL, $html contains the bare URL string — the filter still fires so you can post-process it. Use $feed_url when you need the original unmodified feed URL regardless of how $html has been modified by other callbacks.

Affects

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