dowaw80220 2019-07-09 13:57
浏览 78
已采纳

我正在寻找创建一个函数来增加ACF循环中数据选择器的值

I'm working on a WP site with ACF (flexible content) and AOS.js

I'm trying to have the data-as-delay increment with each element added to the page.

I have tried wrapping everything in a <ul><li> but then I'd have to change all my CSS to accommodate. Since I'm trying to learn, I figured I'd try to create a function. But I don't know where to start.

<?php while ( have_rows('panneau') ) : the_row(); ?>
  <div class="col" data-aos="fade-right" data-aos-delay="200">
    <?php $image = get_sub_field('image'); if( !empty($image) ): ?>
      <img src="<?= $image['url']; ?>" alt="<?= $image['alt']; ?>" />
    <?php endif; ?>
  </div>
<?php endwhile; ?>

So I'd like every new img to have 200ms more delay!

  • 写回答

1条回答 默认 最新

  • dpg78570 2019-07-09 14:43
    关注

    A simple incremator in your loop should do the trick.

    <?php $i = 200; ?>
    
    <?php while ( have_rows('panneau') ) : the_row(); ?>
      <div class="col" data-aos="fade-right" data-aos-delay="<?php echo $i; ?>">
        <?php $image = get_sub_field('image'); if( !empty($image) ): ?>
          <img src="<?= $image['url']; ?>" alt="<?= $image['alt']; ?>" />
        <?php endif; ?>
      </div>
    
    <?php $i = $i + 200;?>
    
    <?php endwhile; ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站