String. HTMl code of the playlist. An empty string if the specified type is not supported.
Usage
wp_playlist_shortcode( $attr );
$attr(array) (required)
Array of output parameters for the playlist. Supports the following parameters:
type(string)
Type of the output playlist: audio or video. Default: 'audio'
order(string)
Direction of sorting the playlist items: ASC or DESC. Default: 'ASC'
orderby(string)
Column or columns of the wp_posts table by which to sort the playlist items. If the ids parameter is specified, this parameter defaults to post__in, meaning to sort by the order of the specified IDs.
For more details on possible values and this parameter in general, refer to the description of WP_Query. Default: 'menu_order ID'
id(int)
ID of the post whose attachments will be collected in the playlist. If the ids parameter is specified, this parameter is ignored. Default: 0 (ID of the post from the global variable $post)
ids(array/string)
ID of attachments from which to collect the playlist. Overrides the ID parameter. Can be specified as a string (IDs separated by commas) or as an array. For more details, see the include parameter from get_posts(). Default: ''
exclude(array/string)
List of attachment IDs to exclude from the list. Can be specified as a string (IDs separated by commas) or as an array. Default: ''
style(string)
Styles for the appearance of the playlist: light or dark. Default: 'light'
tracklist(boolean)
Show or hide the playlist. Default: true
tracknumbers(boolean)
Show or not show the ordinal number of the playlist item. Default: true
images(boolean)
Show or not show the thumbnail of the playlist item: audio or video. Default: true
artists(boolean)
Show or not show the name of the artist of the playlist item. Default: true
About the WordPress shortcode [playlist]
Since version 3.9, WordPress supports the shortcode [playlist], which allows for convenient output of lists of audio or video files attached to a post. Here are various ways to call such a shortcode:
Basic call with default parameters. Will create a playlist of all audio files attached to the post:
[playlist]
Will change the playlist style to dark:
[playlist style="dark"]
Will change the file type from audio to video:
[playlist type="video"]
Let's specify the IDs of the audio files (attachments from the media library) from which the playlist will be assembled.
[playlist ids="123,456,789"]
Let's specify that the provided IDs are video files and change the style to dark:
Suppose we need to display a playlist after the content, which will contain all the audio files attached to the posts. In other words, we need to do what the [playlist] shortcode does.
#2 Display the playlist of the specified video files
Let's say we know the IDs of the videos added to the media library, which are 54,132. And now, we need to list these videos in black design (with dark theme).
The function can be completely overridden by the hook post_playlist. Exactly as it is done with the gallery shortcode in the example function gallery_shortcode()
add_filter( 'post_playlist', 'my_playlist_shortcode', 10, 3 );
function my_playlist_shortcode( $empty_str, $attr, $instance ){
// check what we need, and if it fits, redefine the entire wp_playlist_shortcode function
if( $attr['type'] !== 'video' ){
return '';
}
// here we write our own code to output the playlist for video files
}