Skip to main content

benecaster_episode_embed_audio

Filter Free

Filters the rendered HTML for the embedded audio player on the episode page. Use to swap in a custom player or add attributes.

Return an HTML string. Benecaster casts it with (string) and sanitises it with WordPress’s post allowlist plus <iframe>: an iframe is kept only when it loads from an https:// address, and a <script> or <style> is removed with its contents.

Fires in two templates with the same two arguments — the single episode player (episode/player.php) and the archive card player (archive/episode-card/player.php) — so a callback cannot tell them apart and changes both. Scope by $episode_id if that matters.

Only runs when a non-empty embed already exists.

Parameters

Name Type Default Description
$html string — Rendered audio player HTML
$episode_id int — ID of the episode
$show_id int — ID of the show

Returns: string

Example

add_filter( 'benecaster_episode_embed_audio', function( $html, $episode_id, $show_id ) {
    // Add a preload="none" attribute to defer audio loading until user interaction.
    return str_replace( '<audio ', '<audio preload="none" ', $html );
}, 10, 3 );

Affects

  • Episode page player

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