Wordpress ACF中继器未在列表中显示第一个
在前端显示“我的中继器”字段时,它将显示该列表中除第一项之外的所有内容。我希望它能显示转发器中的所有内容Wordpress ACF中继器未在列表中显示第一个,wordpress,advanced-custom-fields,Wordpress,Advanced Custom Fields,在前端显示“我的中继器”字段时,它将显示该列表中除第一项之外的所有内容。我希望它能显示转发器中的所有内容 <?php if( have_rows('the_list') ): the_row(); ?> <div class="row"> <?php while( have_rows('the_list') ): the_row(); ?> <div class="col-md-8"> <h6&
<?php if( have_rows('the_list') ): the_row(); ?>
<div class="row">
<?php while( have_rows('the_list') ): the_row(); ?>
<div class="col-md-8">
<h6><?php the_sub_field('name') ?></h6>
<p><?php the_sub_field('number') ?></p>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
您正在运行行()代码>两次。从if语句后删除此项可以解决问题
以下是更新的代码段:
<?php if( have_rows('the_list') ): ?>
<div class="row">
<?php while( have_rows('the_list') ): the_row(); ?>
<div class="col-md-8">
<h6><?php the_sub_field('name') ?></h6>
<p><?php the_sub_field('number') ?></p>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
请发布您的代码,以便我们提供帮助。@mbacon40我已经添加了用于提取此代码的代码段。您能检查后端的第一行是否为空吗?
<?php global $post; ?>
<?php if( have_rows('the_list'), $post->ID ): ?>
<div class="row">
<?php while( have_rows('the_list'), $post->ID ): the_row(); ?>
<div class="col-md-8">
<h6><?php the_sub_field('name') ?></h6>
<p><?php the_sub_field('number') ?></p>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>