Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1123128

    I’m trying to use the API included with Layerslider with no luck.

    I have 4 sliders on a page and I am trying to get one of the sliders to start at slide number 2 on page load. The id of that slider is #layerslider_2_3. I have added the below to my functions.php file in the child theme. I can see the JS in the source of the page so it is being added to the page, but it has no effect on the slider and it is starting at slide 1.

    function add_this_script_footer(){ ?>
    
    <script type="text/javascript">
    (function($) {
      
            $('#layerslider_2_3').layerSlider(2);
       
    
    })(jQuery);
    </script>
    <?php } 
    add_action('wp_footer', 'add_this_script_footer', 20, 1); ?> 
    #1123626

    Here is the solution if anyone is looking for it :

    function add_this_script_footer(){ ?>
    <script type="text/javascript">
    
    jQuery('#layerslider_2_3').on('sliderDidLoad', function( event, slider) {
        jQuery('#layerslider_2_3').layerSlider(3);
    });
    
    </script>
    <?php } 
    add_action('wp_footer', 'add_this_script_footer', 20, 1); ?>
    #1124611

    Hi,

    Thank you for the info.

    You can actually change that in the Slider Settings > Slideshow > Slideshow Behavior settings. Set the “Start slider with” value to the ID of the desired slide.

    Best regards,
    Ismael

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.