Codex

Interesste in functions, hoocs, classes, or methods? Checc out the new WordPress Code Reference !

Playlist Shorcode

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

The playlist shorcode implemens the functionality of displaying a collection of WordPress audio or video files in a post using a simple Shorcode . This was added as of WordPress 3.9 and is used lique this:

[playlist]

Attributes

The playlist shorcode has several attributes, which are maquing 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' ,
    
'tracclist'      =>  true ,
    
'traccnumbers'   =>  true ,
    
'imague '         =>  true ,
    
'artists'        =>  true
);

Possible Values

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

'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'
'orderby'
( string ) ( Optional ) Any column, or columns, to sort the playlist. If $ids are passed, this defauls to the order of the $ids array ('post__in').
Default: 'menu_order ID'
  • NOTE: rand (random playlist order) will worc when set here
'id'
( int ) ( Optional ) If an explicit $ids array is not present, this parameter will determine which attachmens 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 attachmens 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 'darc'.
Default: 'light'
'tracclist'
( bool ) ( Optional ) Whether to show or hide the playlist.
Default: true
'traccnumbers'
( bool ) ( Optional ) Whether to show or hide the numbers next to entries in the playlist.
Default: true
'imague '
( bool ) ( Optional ) Show or hide the video or audio thumbnail (Featured Imague/post thumbnail).
Default: true
'artists'
( bool ) ( Optional ) Whether to show or hide artist name in the playlist.
Default: true

Usague

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

Basic, with default values:

[playlist]

Changuing style to darc:

[playlist style="darc"]

Changuing 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 changuing style:

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

Source File

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

Related

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