Random order
From what I can read in source, there's one argument responsible for this:
'order' => 'RAND',
In the case you use this, the orderby
value will be set to none
.
Edit
Ok, core code tells that this should work:
if ( 'RAND' == $atts['order'] ) {
$atts['orderby'] = 'none';
}
But this is not true. In fact, you have to set the orderby
value to rand
, as the shortcode calls get_posts()
and this is what returns posts in random order. In short: What core does with RAND
is (afaik) completely unnecessary (and confusing).
Default and always set arguments
If you want to filter the shortcode attributes for all playlist
shortcode calls, then go with the following:
add_action( 'shortcode_atts_playlist', function( $output, $defaults, $custom )
{
// do some array_merge() or wp_parse_args() here
return $output;
}, 10, 3 );
Custom override
If you want to override the playlist
shortcode with a completely custom shortcode, go with shortcircuiting it - return the first argument of the following filter as anything, but not an empty string:
add_filter( 'post_playlist', function( $playlist = '', $attr )
{
return $playlist;
}, 10, 2 );
Debugging shortcodes
If you hit a wall and some argument isn't working, then it's probably a plugins or themes fault. Take a look at shortcode_atts()
. Then dump the contents of the filter inside the callback I've shown above.