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); ?>
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); ?>