wordpress - ACF 中继器 - 应用不同的行最后一个中继器
问题描述
我在我的 wordpress 网站中使用 ACF 中继器。
每个中继器显示在col-md-6
. 我想显示最后一个col-md-12
.
<div class="container">
<?php if ( have_rows( 'salon' ) ) : ?>
<div class="row">
<?php while ( have_rows( 'salon' ) ) : the_row(); ?>
<div class="col-md-6">
<div class="card">
<div class="card-body">
<h2 class="card-title">Card title</h2>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
</div>
解决方案
用你的代码试试这个例子,它对我有用。
<?php if( have_rows('services_repeater', $services) ): ?>
<?php $rowCount = count( get_field('services_repeater', $services) ); //GET THE COUNT ?>
<?php $i = 1; ?>
<?php while( have_rows('services_repeater', $services) ): the_row(); ?>
<?php // vars
$service = get_sub_field('service');
$description = get_sub_field('description');
?>
<span class="hint--bottom" data-hint="<?php echo $description; ?>"><?php echo $service; ?></span>
<?php if($i < $rowCount): ?>
<div id="separator"> / </div>
<?php endif; ?>
<?php $i++; ?>
<?php endwhile; ?>
<?php endif; ?>
推荐阅读
- r - 将 UpdateTabsetPanel 与动态 UI 一起使用
- typescript - 如何将对象键的值映射到 TypeScript 中的同一对象?
- android - Resources$NotFoundException: Unable to find resource ID #0xffffffff using NestedScrollView with Motionlayout
- heroku - 使用从文件部署终端heroku到服务器
- git - 用(当前)非git文件夹替换分支中的所有文件和文件夹
- c - 为什么 C 中 malloc 的类型转换在右边而不是左边有 * 符号?
- swift - 从 Swift 中另一个字符串的引用字符中获取字符
- c - 在整数序列中查找距离 D 范围内有多少对数字
- node.js - 无法在 Node.js 中导入 firebase-admin
- mysql - 如何选择具有最新日期的行并根据该行计算另一个字段