【问题标题】:ACF repeater - apply different row last repeaterACF 中继器 - 应用不同的行最后一个中继器
【发布时间】:2021-09-05 18:49:17
【问题描述】:

我在我的 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>

【问题讨论】:

    标签: wordpress bootstrap-4 advanced-custom-fields


    【解决方案1】:

    用你的代码试试这个例子,它对我有用。

    <?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; ?>
    

    【讨论】:

      猜你喜欢
      • 2015-02-17
      • 2015-03-30
      • 2016-07-02
      • 1970-01-01
      • 1970-01-01
      • 2019-10-16
      • 2018-04-02
      • 1970-01-01
      • 2019-02-03
      相关资源
      最近更新 更多