When no attribute is used but a value is provided, the value is added to $atts[0]
. Using $atts[0]
, I’m now able to get the value output doing the following:
function audio_shortcode($atts) {
if($atts[0] != '') {
return '
<div class="audiofile">
<audio controls>
<source src="' . $atts[0] . '" type="audio/mpeg">
</audio>
</div>';
}
}
add_shortcode('audio', 'audio_shortcode');