Search code examples
randomwordpresssliderrevolution-slider

Wordpress - Randomize text over a slider [Revolution Slider or similar]


I'm using the Revolution Slider plugin for Wordpress. I have 5 images in my slider and I have 30 short texts. I want to show randomly displaying 1 of these 30 texts every time the slider change image. Can you suggest me how can I do (also changing plugin)

Thanks


Solution

  • This can be easily added by a short script and a css rule.

    The CSS Part

    .forcenoshow { display:none !important} 
    

    The JS Part

    jQuery('#yoursliderid').bind('.revolution.slide.onafterswap',function() {
      var randomindex = Math.round(Math.random()*30);
      jQuery('.current-sr-slide-visible').find('.tp-caption').each(function(i) {
          if (i!==randomindex) jQuery(this).addClass("forcenoshow");
    });
    

    This will give all layers within the current slide a "display:none !important" attribute to hide the layer. Only 1 layer from the slide will be visible.

    More FAQ and Answer at: http://themepunch.com/support-center