Display Random YT Video

By Whane The WhipWhane The Whip


Thanks to ListPages, having a random video display on your site is easy. You would start by creating a category in which to display each video by pasting the embed code from each youtube video within an [[html]] block, one video per page. For example: video:1, video:2, video:3, etc…

Then use listpages (code seen below) to randomly display 1 video and place the listpage code where ever you wish for your random video to be seen. The Random order option will refresh every 60 seconds. I like to put videos in the side bar and using this method helps to keep new videos appearing for visitors that like fresh content.


[[module ListPages category="video" perPage="1" order="random" limit="1"]]

In action

You can see this in action on my Wikidot Random Video page.. Refresh the page about a minute after you arrive and you should see the video in the sidebar change. There is a slight chance that the same video will appear twice in a row. The more videos you have in the rotation, the least likely this is to happen.


Wikidot Categories
HTML Scripting in Wikidot
The ListPages Module

Thanks to tsangk for this great snippet: conditional-blocks

text above inserted with:

[[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]
[[include :snippets:if END]]

Other snippets posted by Whane The Whip

Rate this solution

If you think this solution is useful — rate it up!

rating: +2+x
Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License