Hi @invisibleillness,
You can try the following code snippet (that’s using the youlist_src
filter) to start the playlist at a random video:
/**
* Play random video from the playlist
*
* Tested on YouList version 1.0.6
*
* Example:
* [youlist pid="PL3FF15AA7ED356D9F" parameters="&myrandom"]
*
* @param string $src YouTube source string
* @return string $src Modified YouTube source string
*/
function my_random_playlist_video( $src )
{
$number_of_videos_in_playlist = 20; // Edit this to your needs
$from = 'myrandom';
$to = sprintf( 'index=%d', rand( 0, $number_of_videos_in_playlist ) );
$src = str_replace( $from, $to, $src );
return $src;
}
add_filter( 'youlist_src' , 'my_random_playlist_video' );
where you have to add
parameters="&myrandom"
into your shortcode.
You can for example add this code snippet into your functions.php
file in the current theme directory.
ps: The plugin is now available on github:
https://github.com/birgire/wp-youlist