• Resolved leoly

    (@leoly)


    Hello,
    We have the following shortcode for a Playlist –
    [lyte id="PLID" audio=”true” playlist=”true” /]

    We would like for the playlist to start from a random number – which was achieved by doing the following and adding to a PHP page template –
    <iframe src="https://www.youtube.com/embed?listType=playlist&list=PLID&index=<?php print(rand(1,200)) ?>" width="560" height="315" frameborder="0"></iframe>

    We can get the shortcode to work from the template via –
    <?php echo do_shortcode('[lyte id="PLID" audio=”true” playlist=”true” /]'); ?>

    Is there a way to add the &index into the shortcode, so that the playlist can start from a random number? The iframe does what we need, but we like the audio-only feature of the plugin. So if there is a way to style the iframe to look like the audio-only styling, that would help as well. Thanks.

Viewing 3 replies - 16 through 18 (of 18 total)
  • Plugin Author Frank Goossens

    (@futtta)

    can’t stand it when something does not work, so brace yourself for the regex solution;

    add_filter('lyte_match_postparse_template','playlist_randomizer');
    function playlist_randomizer($in) {
      return preg_replace('/class="(lyMe [^"]*)"/','class="$1 qsa_\&index\='.rand(1,200).'"',$in);
    }
    

    GO! ??

    Thread Starter leoly

    (@leoly)

    ??Hurray?? LOL. It worked. Both audio only and full video shortcodes, and even regular YouTube links work. Amazing solution, thanks for figuring it all out.

    Plugin Author Frank Goossens

    (@futtta)

    you’re welcome @leoly, enjoy the weekend ??

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘Shortcode For Playlist’ is closed to new replies.