【发布时间】:2018-05-19 06:20:03
【问题描述】:
我将滑块与中继器字段结合在一起。 在中继器下,我有 2 个子字段。一个叫“图片”,另一个叫“标题”
this slider has a class called “selected-item” that dynamically appear when an image is selected. (当这个类在图像上时,图像会改变它的大小)。
我如何定义当“选定项”类在某个图像上时,图像同一行的“标题”也会出现?
这是显示图像的代码:
<?php
// check if the repeater field has rows of data
$i = 1;
if( have_rows('carousel_images') ):
// loop through the rows use_cases_fields data
while ( have_rows('carousel_images') ) : the_row();
$title=get_sub_field('image_carousel_discription');
$image = get_sub_field('image_carousel1');
if( !empty($image) ):
// vars
// thumbnail
$thumb = $image;
$i++;
?>
<h1 data-row="< echo $i; >"> <?php echo $title ?> </h1>
<li> <a href="#home"><img data-row="< echo $i; >" src="<?php echo $thumb ?>"/></a> </li>
<?php endif; ?>
<?php
endwhile;
endif;
?>
?>
【问题讨论】:
-
我会在您的 jQuery 滑块中包含一个回调来查找“数据行”属性,然后显示相同“数据行”值的 h1。你用什么 jQuery 来滑动你的图片?
-
你是指哪个版本?
-
不,抱歉。我应该更清楚。您使用的是哪个滑块?它是插件、jQuery 库还是什么?
-
这是一个jquery库,叫做jquery sky carousel
-
答案如下。您应该能够听到对轮播的点击或在滑块的回调上运行函数。
标签: wordpress slider repeater advanced-custom-fields