Title: Audio Shortcode
Author: Dion Hulse
Published: 2 Novembre 2018
Last modified: 27 Giugno 2020

---

# Audio Shortcode

The Audio feature allows you to embed audio files and play them back using a simple
Shortcode. This was added as of WordPress 3.6 and is used like this:

    ```wp-block-preformatted
    [ audio]
    ```

Note: Do Not put Space between “[” and “audio”.

You can also use build in embeds and simply put the media file on it’s own line:

    ```wp-block-preformatted
    My cool contenthttp://my.mp3s.com/cool/songs/coolest.mp3More cool content
    ```

## Usage

I have an old post that has an audio file in the Media Library attached to it, and
I want to use the new shortcode:

    ```wp-block-preformatted
    [ audio]
    ```

Note: Do Not put Space between “[” and “audio”.

I have the URL for an MP3, from the Media Library or external, that I want to play:

    ```wp-block-preformatted
    [audio src="audio-source.mp3"]
    ```

I have a source URL and fallbacks for other HTML5-supported filetypes:

    ```wp-block-preformatted
    [audio mp3="source.mp3" ogg="source.ogg" wav="source.wav"]
    ```

## Options

The following basic options are supported:

**src**

([string](https://codex.wordpress.org/How_to_Pass_Tag_Parameters#String)) (optional)
The source of your audio file. If not included it will auto-populate with the first
audio file attached to the post.      You can use the following options to define
specific filetypes, allowing for graceful fallbacks:

 * ‘mp3’, ‘m4a’, ‘ogg’, ‘wav’, ‘wma’ Default: First audio file attached to the post

 
 **loop** ([string](https://codex.wordpress.org/How_to_Pass_Tag_Parameters#String))(
optional) Allows for the looping of media.

 * “off” – Do not loop the media.”on” – Media will loop to beginning when finished
   and automatically continue playing. Default: “off”

**autoplay**
 ([string](https://codex.wordpress.org/How_to_Pass_Tag_Parameters#String))(
optional) Causes the media to automatically play as soon as the media file is ready.

 * “off” – Do not automatically play the media.
 * “on” – Media will play as soon as it is ready. Default: “off”

 
 **preload** ([string](https://codex.wordpress.org/How_to_Pass_Tag_Parameters#String))(
optional) Specifies if and how the audio should be loaded when the page loads. Defaults
to “none”

 * “none” – The audio should not be loaded when the page loads.
 * “auto” – The audio should be loaded entirely when the page loads.
 * “metadata” – Only metadata should be loaded when the page loads. Default: “none”

## Related

WordPress Shortcodes: [](https://it.wordpress.org/support/article/audio-shortcode/?output_format=md)
[audio](https://wordpress.org/support/article/audio-shortcode/), [](https://codex.wordpress.org/Caption_Shortcode)
[caption](https://codex.wordpress.org/caption), [](https://codex.wordpress.org/Embed_Shortcode)
[embed](https://codex.wordpress.org/embed), [](https://codex.wordpress.org/Gallery_Shortcode)
[gallery](https://it.wordpress.org/support/article/the-wordpress-gallery/?output_format=md#gallery-shortcode),
[](https://codex.wordpress.org/Playlist_Shortcode)[playlist](https://codex.wordpress.org/playlist),
[](https://codex.wordpress.org/Video_Shortcode)[video](https://it.wordpress.org/support/article/video-shortcode/?output_format=md)