我正在尝试在Wordpress中使用Bootstrap轮播,因此我需要进行循环.但是,滑条脚本要求第一张幻灯片具有特殊的类,并且无法说明如何将该类应用于循环的第一次迭代,而仅应用于循环(实际上,当轮播时,该类将在整个幻灯片中旋转可以使用,但是html需要首先包含具有活动类的幻灯片,然后具有该类的所有其他幻灯片).
到目前为止,这是我的代码:
因此,简而言之,我需要的是这一行:
仅一次,但所有其他迭代应为
任何帮助真的很感激
解决方法:
如果只想出现一次,请使用$i变量.
// This sets the value to 0
$i = 0;
while( have_rows('slide') ): the_row();
// vars
$img = get_sub_field('slide_image');
$desc = get_sub_field('slide_text');
$title = get_sub_field('slide_title');
$url = $img['url'];
$size = 'slider';
$thumb = $gal['sizes'][ $size ];
?>
// This will increment $i so $i should not
// equal 0 except on the first loop
$i++;
endwhile; ?>
标签:twitter-bootstrap,wordpress,php
来源: https://codeday.me/bug/20191121/2049416.html