Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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');
share|improve this answer
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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