On my website, I had a plugin, that displayed a media tag like [audio src=path/file.mp3]. It returned this tag in the HTML retruned from the shortcode function.

function init() { add_shortcode('myshortcode', array($this, 'myshortcode_shortcode'); } function myshortcode_shortcode() { return '[audio src=path/file.mp3]'; }

This used to work by displaying the default html5 media player of wordpress. Since an automatic update of Wordpress in August, this doesn't work anymore. The text [audio src=path/file.mp3] is now displayed on the webpage, instead of the mp3 player.

I guess this is due to a new security feature of wordpress.

How can I get the media player back?

1 Answer 1


You may need to update your shortcode function to generate the audio player using proper HTML markup instead of returning the raw shortcode text. Here's an example:

function myshortcode_shortcode() {
    $audio_url = 'path/file.mp3';
    $audio_markup = '<audio controls><source src="' . esc_url($audio_url) . '" type="audio/mp3"></audio>';
    return $audio_markup;
  • That's what I did. I hoped there was a way to do this using a wordpress tag. Dec 6, 2023 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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