【发布时间】:2017-10-02 22:41:00
【问题描述】:
问题:如何简单地计算 ACF 转发器字段输出中的行数?
目标:当只有一行而不是多行时,使用 css 类使输出看起来不同。
我的代码:
if( have_rows('testimonials')) {
$counter = 0;
$numtestimonials = '';
//loop thru the rows
while ( have_rows('testimonials') ){
the_row();
$counter++;
if ($counter < 2) {
$numtestimonials = 'onlyone';
}
echo '<div class="testimonial ' . $numtestimonials . '">';
// bunch of output here
echo '</div>';
}
}
显然,我在这里执行的方式不起作用,因为第一次通过该行的计数为
谢谢!
【问题讨论】:
标签: php mysql wordpress repeater advanced-custom-fields