function gallery_script_function() {?>
<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/css/splide.min.css">
<script src="<?php echo get_stylesheet_directory_uri(); ?>/js/splide.min.js"></script>
<script>
jQuery(document).ready(function(){
new Splide( '.splide' ).mount();
var slides = jQuery('.splide__list li').length;
if(slides<=1){
jQuery('.splide__arrows').hide();
}
});
</script>
<?php }
add_action( 'wp_footer', 'gallery_script_function' );
add_shortcode( 'gallery_img', 'gallery_img_shortcode' );
function gallery_img_shortcode( $atts ) {
ob_start();
$gal_images = get_field('additional_gallery_images', get_the_ID());
$size = 'full'; // (thumbnail, medium, large, full or custom size)
if( $gal_images ): ?>
<div class="splide direc_gall">
<div class="splide__track">
<ul class="splide__list">
<?php foreach( $gal_images as $image_id ): ?>
<li class="splide__slide">
<?php echo wp_get_attachment_image( $image_id, $size ); ?>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
<?php endif;
$galvariable = ob_get_clean();
return $galvariable;
}
Jagdish Sarma Asked question November 17, 2021