post_playlist filter
Filters the playlist output.
apply_filters( 'post_playlist', string $output, array $attr, int $instance )
Description
This is filter hook , which is used for filter the playlist output.
Returning a non-empty value from the filter will short-circuit generation of the default playlist output, returning the passed value instead.
Parameters
- $output : (string) Playlist output. Default empty.
- $attr : (array) An array of shortcode attributes.
- $instance : (int) Unique numeric ID of this playlist shortcode instance.
Live Example
/** * Passing a non-empty value to the filter will short-circuit the default output. * * @param string $output Playlist output. Default empty. * @param array $attr An array of shortcode attributes. * @param int $instance Unique numeric ID of this playlist shortcode instance. */ function wpdocs_mytheme_custom_playlist( $output, $attr, $instance ) { if ( 'false' == $attr['images'] || 'video' == $attr['type'] ) { => $label ) { $thumb_id, 'full' ); , 'height' ); $thumb_id, $cover_size ); , 'height' ); ] ); > ></<?php echo $safe_type; ?>> echo wp_json_encode( $data ); ?></script>
To run the hook, copy the example below.
$var = apply_filters( 'post_playlist', $var, $attr, $instance ); if ( !empty( $var ) ) { // everything has led up to this point... }
The following example is for adding a hook callback.
// define the post_playlist callback function filter_post_playlist( $var, $attr, $instance ) { // make filter magic happen here... return $var; }; // add the filter add_filter( 'post_playlist', 'filter_post_playlist', 10, 3 );
To remove a hook callback, use the example below.
// remove the filter remove_filter( 'post_playlist', 'filter_post_playlist', 10, 3 );