1

I hope you guys can help me with this little bug I've encountered. I am using a shortcode to display an audio player in the entries.

This is the code i've put in my functions.php:

function html5_audio($atts, $content = null) {
extract(shortcode_atts(array(
    "src" => '',
    "preload"=> 'none',
    "loop" => ''
), $atts));
return '<audio src="'.$src.'" preload="'.$preload.'" loop="'.$loop.'" />';
}
add_shortcode('audio', 'html5_audio');

And this is the shortcode:

[audio src=""]

The shortcode itself is working and displaying the audio player. But any other content that is posted after the shortcode within that post won't appear on the blog. I tried embedding the audio file directly with <audio> and it worked. So HTML5 is working alright. Only the shortcode seems to be causing trouble.

Any help is appreciated! Thanks in advance.

1

You forgot the closing </audio> tag at the end.

function html5_audio($atts, $content = null) {
extract(shortcode_atts(array(
    "src" => '',
    "preload"=> 'none',
    "loop" => ''
), $atts));
return '<audio src="'.$src.'" preload="'.$preload.'" loop="'.$loop.'" /></audio>';
}
add_shortcode('audio', 'html5_audio');
  • 1
    Thank you so much! I feel like a fool for overlooking that. I was looking for much more complex problems. It's working now. – charlenemasters Aug 5 '12 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.