Skip to content

Instantly share code, notes, and snippets.

@marcelo2605
Created June 22, 2018 17:33
Show Gist options
  • Save marcelo2605/853c499b01a9084d9ce94d8f788e5357 to your computer and use it in GitHub Desktop.
Save marcelo2605/853c499b01a9084d9ce94d8f788e5357 to your computer and use it in GitHub Desktop.
Add an audio description with the audio player.
add_filter('wp_audio_shortcode', function ($html, $atts, $audio, $post_id, $library) {
$media_id = attachment_url_to_postid($atts['mp3']);
if (0 !== $media_id) {
$content = get_post_field('post_content', $media_id);
$content = apply_filters('the_content', $content);
if (!empty($content)) {
$html = $html.'<div class="audio-description">'.$content.'</div>';
}
}
return $html;
}, 10, 5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment