benecaster_episode_link_output
Filters the final rendered HTML of the [benecaster_episode_link] shortcode before it is returned. This shortcode is inserted by the TipTap editor’s @ mention picker and renders as an inline anchor wherever users insert episode links — in episode descriptions, production notes, and other rich-text fields.
Use this filter to change the anchor markup, add data attributes, apply CSS classes, or wrap the link in additional elements. Changes apply across all placements of episode links without requiring edits to the editor or stored content.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$html |
string |
— | Rendered anchor HTML |
$episode_id |
int |
— | ID of the linked episode |
$atts |
array |
— | Resolved shortcode attributes including episode_id, show_id, and label |
Returns:
string
Examples
Add episode number data attribute
add_filter( 'benecaster_episode_link_output', function( $html, $episode_id, $atts ) {
// Add a data attribute with the episode number for JS-driven highlighting.
$ep_number = get_post_meta( $episode_id, '_benecaster_episode_number', true );
if ( $ep_number ) {
$html = str_replace( '<a ', '<a data-episode-number="' . absint( $ep_number ) . '" ', $html );
}
return $html;
}, 10, 3 );
Add analytics data attribute
add_filter( 'benecaster_episode_link_output', function ( string $html, int $episode_id, array $atts ): string {
return str_replace( '<a ', '<a data-episode-id="' . $episode_id . '" ', $html );
}, 10, 3 );
Apply custom CSS class
add_filter( 'benecaster_episode_link_output', function ( string $html, int $episode_id, array $atts ): string {
return str_replace( 'class="benecaster-episode-link"', 'class="benecaster-episode-link ep-internal-link"', $html );
}, 10, 3 );
Notes
The [benecaster_episode_link] shortcode is an inline TipTap node inserted via the @ mention picker. Changes made here apply across all placements — episode descriptions, production notes, and any other rich-text field that supports inline episode links.
Affects
- [benecaster_episode_link](/shortcodes/benecaster-episode-link/) shortcode
- Episode Link TipTap node (inline)