N
N
neytan2018-04-26 09:34:10
Slick
neytan, 2018-04-26 09:34:10

How to dynamically add sliders in wordpress?

Good afternoon, tell me how you can dynamically add sliders in wordpress? There is a portfolio page and works are added through the wordpress admin panel and each work contains a slider. If you add a slider in the standard way, then you need to prescribe initialization for each slider in js:

$('.carousel-wrap-1').slick({
      dots: false,
      infinite: true,
      speed: 600,
      slidesToShow: 5.0,
      slidesToScroll: 1,
</script>

It is desirable to suggest a solution for slick slider, but can you suggest something else, not critical.
And the slider is displayed through the advanced custom fields pro gallery with the following code:
<div class="stend-slider-wrap">
  <?php
  $images = get_field('photo_stand');
  if( $images ): ?>
    <div class="stend-slider">
      <?php foreach( $images as $image ): ?>
        <a href="<?php echo $image['url']; ?>" data-fancybox="images">
          <img src="<?php echo $image['sizes']['portfolio-item-thumb']; ?>" alt="<?php echo $image['alt']; ?>" />
        </a>
      <?php endforeach; ?>
    </div>
  <?php endif; ?>
</div>

Even if you want to attach a unique div wrapper (class="slider1", class="slider-2"...) to each slider, it will not work, since the call code is set 1 time, and then the portfolio is automatically generated from the admin panel.
And how is it possible to make data-fancibox different for each portfolio, so that fancybox would normally put and switch pictures of only one portfolio in it? I attach the screenshot5ae172d0a7fa6636582540.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
ljutaev, 2018-04-26
@neytan

Why do you need to initialize each slider if you have the same styles and parameters as well. You set a unique class and initialize. I did this, but with owl-carousel

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question