Hide one slide from loop and show it only once.

On my home page https://****tage.com/ I use LayerSlider WP. I am trying to prevent one slide from looping in that slider.
I've done it before, but no longer have the slider. I did it on the copy, there is space to add custom css to the slider.

  • Ash
    • WordPress Hacker

    Hello mary

    Please try the following code:

    add_action( 'wp_head', function() {
    	?>
    	<style>
    		.forceHidden {
    			display: none !important;
    		}
    	</style>
    	<script>
    		jQuery(function($){
    			var obj = $('.ls-wrapper.ls-in-out[data-slide-index="2"]'),
    				counter = 0;
    
    			var interval = setInterval(function() {
    				if( obj.is(':visible') ) counter++;
    				if( counter > 0 ) {
    					if( ! obj.is(':visible') ) {
    						obj.addClass('forceHidden');
    						clearInterval(interval);
    					}
    				}
    			}, 100);
    		});
    	</script>
    	<?php
    } );

    You can use this code in your child theme's functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

    Hope it helps! Please feel free to ask more questions if you have any.

    Have a nice day!

    Cheers,
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.