How to print or echo a random php string on page load or refresh?

I am using WordPress’ Revolution Slider (aka Slider Revolution) in which I have create 3 different sliders. Each slider only contains 1 video each which I am using as a full width background on the home page kind of like the Aribnb website.

I want the sliders to load in random order so that each time a user visits the home page they get a random new video/slider. My markup for the sliders receptively for each is as follows…

Read More
<?php putRevSlider("slider1") ?>
<?php putRevSlider("slider2") ?>
<?php putRevSlider("slider3") ?>

How can I make just one of these print or echo at random on my home page each time the page is refreshed?

RELEVANT INFO: The reason I made 3 sliders instead of adding all 3 videos in 1 single slider and setting them in random order as RevSlider already supports is because I don’t want the videos to play one after the other which is why I have set each one of them to loop on their own individual slider.

Related posts

Leave a Reply

2 comments

  1. <?php
    $SliderNumber = rand(1,3);              //random number between 1 and 3
    $SliderName = "slider" . $SliderNumber; //will either be "slider1", "slider2", or "slider3"
    putRevSlider($SliderName);
    ?>