将下一个和上一个ACF字段设为当前

时间:2018-04-18 07:52:15

标签: javascript jquery wordpress loops advanced-custom-fields

我有一个光滑滑块的ACF循环。我试图将上一张和下一张幻灯片标题改为当前版本。

<?php if (have_rows('videofeed','option')): ?>
<div class="slider-popular">
            <?php while (have_rows('videofeed2','option')) : the_row(); ?>
                <div class="slider-go-wrap slick-current">
                      <h2 class="video-title"> <?php the_sub_field('video_title'); ?> </h2><!-- the video title -->

                    <div class="video-controls">
                                <div class="prev-title-popular">
                                    <span class="controltitles prev-videotitle">PREVIOUS TITLE HERE <?php the_sub_field('video_title'); ?></span> <!-- previous  ACF row sub_field "video_title" here -->
                                </div>

                                <div class="next-title-popular">
                                    <span class="controltitles next-videotitle">NEXT TITLE HERE <?php the_sub_field('video_title'); ?></span><!-- next ACF row sub_field "video_title" here -->
                                </div>
                    </div>
                </div>
            <?php endwhile;?>
</div>     
<?php endif; ?>

我已经掌握了使用jQuery来做到这一点,但似乎无法让它工作。目前我的情况如下:

$('.slider-go-wrap').each(function() {
  currentSlide = $('.slick-current');
   nextSlide = currentSlide.next();
   prevSlide = currentSlide.prev();

   nextSlideData = nextSlide.find('.next-videotitle').html();
   prevSlideData = prevSlide.find('.prev-videotitle').html();
});

JSFiddle:https://jsfiddle.net/px2bvdbt/12/

任何建议将不胜感激。

0 个答案:

没有答案