The post_playlist WordPress PHP filter allows you to customize the output of a playlist by returning a non-empty value. This will override the default playlist generation.
Usage
add_filter('post_playlist', 'your_custom_function', 10, 3); function your_custom_function($output, $attr, $instance) { // your custom code here return $output; }
Parameters
$output
(string): The playlist output. Default is empty.$attr
(array): An array of shortcode attributes.$instance
(int): Unique numeric ID of this playlist shortcode instance.
More information
See WordPress Developer Resources: post_playlist
Examples
Change the playlist output style
Customize the playlist output with a different style.
add_filter('post_playlist', 'change_playlist_style', 10, 3); function change_playlist_style($output, $attr, $instance) { // your custom code to change the playlist style here return $output; }
Add a custom CSS class to the playlist
Add a custom CSS class to the generated playlist output.
add_filter('post_playlist', 'add_custom_css_class', 10, 3); function add_custom_css_class($output, $attr, $instance) { // your custom code to add a CSS class here return $output; }
Add a wrapper around the playlist
Wrap the playlist output in a custom HTML element.
add_filter('post_playlist', 'wrap_playlist', 10, 3); function wrap_playlist($output, $attr, $instance) { // your custom code to wrap the playlist here return $output; }
Remove certain tracks from the playlist
Filter out specific tracks from the playlist output.
add_filter('post_playlist', 'remove_specific_tracks', 10, 3); function remove_specific_tracks($output, $attr, $instance) { // your custom code to remove certain tracks here return $output; }
Add custom metadata to the playlist
Add custom metadata to each track in the playlist.
add_filter('post_playlist', 'add_custom_metadata', 10, 3); function add_custom_metadata($output, $attr, $instance) { // your custom code to add metadata here return $output; }