Skip to content

Instantly share code, notes, and snippets.

@amiad
Created August 12, 2012 21:07
Show Gist options
  • Select an option

  • Save amiad/3334434 to your computer and use it in GitHub Desktop.

Select an option

Save amiad/3334434 to your computer and use it in GitHub Desktop.
add mediaelement player to wordpress excerpt
add_filter( 'the_excerpt', 'add_audio_to_excerpt');
function add_audio_to_excerpt($excerpt){
$content=get_the_content();
$audiopos=strpos($content,'[audio src=');
if(audiopos!=='') {
$audio=substr($content,$audiopos,strpos($content,']')+1);
return do_shortcode($audio.$excerpt);
}
else return $excerpt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment