Codex

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

Playlist Shortcode

This article is marked as in need of editing. You can help Codex by editing it.

The playlist shortcode implements the functionality of displaying a collection of WordPress audio or video files in a post using a simple Shortcode. This was added as of WordPress 3.9 and is used like this:

[playlist]

Attributes

The playlist shortcode has several attributes, which are making it possible to alter its output.

The default values for the attributes are:

Default Values


<?php array(
    
'type'          => 'audio',
    
'order'         => 'ASC',
    
'orderby'       => 'menu_order ID',
    
'id'            => $post $post->ID 0,
    
'include'       => ,
    
'exclude'       => 
,
    
'style'         => 'light',
    
'tracklist'     => true,
    
'tracknumbers'  => true,
    
'images'        => true,
    
'artists'       => true
);

Possible Values

Some values do set others, depending on their arguments. Keep that in mind when something does not work.

'type'
(string) (Optional) Type of playlist to display. Accepts 'audio' or 'video'.
Default: 'audio'
'order'
(string) (Optional) Designates ascending or descending order of items in the playlist. Accepts 'ASC', 'DESC'.
Default: 'ASC'
  • NOTE: RAND won't work here, the documentation that was once here is incorrect, see Trac Ticket #29629
'orderby'
(string) (Optional) Any column, or columns, to sort the playlist. If $ids are passed, this defaults to the order of the $ids array ('post__in').
Default: 'menu_order ID'
  • NOTE: rand (random playlist order) will work when set here
'id'
(int) (Optional) If an explicit $ids array is not present, this parameter will determine which attachments are used for the playlist.
Default: the current post ID
'ids'
(array) (Optional) Create a playlist out of these explicit attachment IDs. If empty, a playlist will be created from all $type attachments of $id.
Default: empty
'exclude'
(array) (Optional) List of specific attachment IDs to exclude from the playlist.
Default: empty
'style'
(string) (Optional) Playlist style to use. Accepts 'light' or 'dark'.
Default: 'light'
'tracklist'
(bool) (Optional) Whether to show or hide the playlist.
Default: true
'tracknumbers'
(bool) (Optional) Whether to show or hide the numbers next to entries in the playlist.
Default: true
'images'
(bool) (Optional) Show or hide the video or audio thumbnail (Featured Image/post thumbnail).
Default: true
'artists'
(bool) (Optional) Whether to show or hide artist name in the playlist.
Default: true

Usage

Generally, shortcodes are used by adding them to the content of the post editor.

Basic, with default values:

[playlist]

Changing style to dark:

[playlist style="dark"]

Changing type to video:

[playlist type="video"]

Specifying ids of audio files, it's the default, out of the media library:

[playlist ids="123,456,789"]

Specifying ids of video files out of the media library and changing style:

[playlist type="video" ids="123,456,789" style="dark"]

Source File

The playlist shortcode is located in wp-includes/media.php.

Related

WordPress Shortcodes: [audio], [caption], [embed], [gallery], [playlist], [video]