Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Customizations for default WordPress audio shortcode and embed.
* Change attribute for WP audio shortcode and embed.
* Default preload attribute is 'none' which shows time as 'O:OO'.
* Setting attribute to 'metadata' displays time upon page load.
* @param string $html Default audio shortcode HTML output.
* @return string $html Filtered audio shortcode HTML output.
function my_audio_preload( $html, $atts, $audio, $post_id, $library ) {
$html = str_replace( 'preload="none"', 'preload="metadata"', $html );
return $html;
add_filter( 'wp_audio_shortcode', 'my_audio_preload', 10, 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment