WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp audio shortcode

Description

Implements the functionality of the Audio Shortcode for displaying (and playing) audio-files in a post. Conditionally adds HTML audio tag (with media player) or fallback HTML.

Default WordPress supported audio formats are: mp3, ogg, wma, m4a, wav.

Usage

 <?php wp_audio_shortcode$attr ?> 

Parameters

$attr
(array) (required) Attributes of the shortcode.
Default: None

Return

(string) 
HTML content to display audio.

Example

Display the HTML for an audiofile and the default media player:

$attr = array(
	'src'      => 'http://example.com/my-audiofile.mp3',
	'loop'     => '',
	'autoplay' => '',
	'preload'  => 'none'
);
echo wp_audio_shortcode( $attr );

Change Log

Source File

wp_audio_shortcode() is located in wp-includes/media.php.

Related

Shortcode API

Audio: wp_audio_shortcode(), wp_get_audio_extensions(), get_attached_media(), wp_embed_handler_audio(), wp_mediaelement_fallback(), wp_read_audio_metadata(), wp_add_id3_tag_data()

See also index of Function Reference and index of Template Tags.