Support » Plugin: YouList - YouTube playlist shortcode » Random order of specific playlist

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hey @invisibleillness

    The origingal YouTube player seems to support the index parameter where you can start playing the i-th video on the playlist.

    So you could try for example:

    [youlist pid="PL3FF15AA7ED356D9F" parameters="&index=2"]

    to start at video number 2 on the playlist.

    ps: I will try to add a random feature in the next update where the indexparameter is some random value, but I can’t see at the moment how I can get the number of videos on the playlist so I might try using some fix like:

    random="1" min="1" max="5"

    Just an idea …

    Thread Starter invisibleillness


    thank you so much! there seems to be a lot of requests out there for this but few options other than the spider player which is $30 (and tech support is trying to help me figure out why it is not working in FF right now.)

    Is there by chance any kind of “shuffle” button on the player? Because I could have it start on a 20-second video of me each time explaining, “hit that little button to shuffle” – I know… silly, but most my audience is chronically ill and sometimes needs some extra instructions.

    So, you are talking to a challenged-coder. should I give it a shot with the random code above and see what happens or were you just thinking out loud? (smile)

    Thank you!

    I will try out this feature next week, when I import the plugin to github.

    I will then post the url.


    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


    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:

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Random order of specific playlist’ is closed to new replies.