Slider Revolution WP
09.27.2016
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// get a list of all available sliders $my_sliders = new RevSlider(); // grab the "alias" names of the sliders $my_slider_array = $my_sliders->getAllSliderAliases(); // randomize magic $my_slider_keys = array_keys($my_slider_array); $my_random_slider_alias = $my_slider_array[$my_slider_keys[rand(0, count($my_slider_keys) - 1)]]; // add the random slider to the page putRevSlider($my_random_slider_alias); |
Now that we’ve generated a slider’s “alias” randomly, it can be used in conjunction with any of the methods listed here. So if we wanted to only include a random slider on the site’s homepage, for example, we could use the following “php method”:
1 2 3 |
putRevSlider("slider1", "homepage"); |
… and change the “slider1” part, to our new randomized alias variable, which would look like this:
1 2 3 |
putRevSlider($my_random_slider_alias, "homepage"); |
… and then the updated code for showing a random slider on the homepage only would look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// get a list of all the sliders $my_sliders = new RevSlider(); // grab the "alias" names of the sliders $my_slider_array = $my_sliders->getAllSliderAliases(); // randomize magic $my_slider_keys = array_keys($my_slider_array); $my_random_slider_alias = $my_slider_array[$my_slider_keys[rand(0, count($my_slider_keys) - 1)]]; // ADD THE RANDOM SLIDER TO THE HOME PAGE ONLY putRevSlider($my_random_slider_alias, "homepage"); |