我正在尝试通过元素页面上的短代码在表格中显示嵌套的 ACF 字段。
我尝试将短代码与我在 google 上找到的一些代码合并,但是我没有成功。
转发器部分取自此链接:https : //support.advancedcustomfields.com/forums/topic/help-with-creating-a-table-using-nested-repeaters/
当我使用短代码时,什么都没有。
function menu_loop() {
ob_start();
?>
<?php if ( have_rows('menu') ):
while ( have_rows('menu') ) : the_row(); ?>
<h2 class="menu-title"><?php the_sub_field('week'); ?><h2>
<?php if ( have_rows('week') ): ?>
<table>
<thead>
<tr class="menus-row">
<td>Days</td>
<td>Snack AM</td>
<td>Lunch</td>
<td>Snack PM</td>
</tr>
</thead>
<?php while ( have_rows('week') ) : the_row(); ?>
<tr class="menu-row">
<td><?php the_sub_field('days'); ?></td>
<td><?php the_sub_field('snack_am'); ?></td>
<td><?php the_sub_field('lunch'); ?></td>
<td><?php the_sub_field('snack_pm'); ?></td>
</tr>
<?php endwhile;?>
</table>
<?php endif;?>
<?php endwhile;?>
<?php endif; ?>
<?php
return ob_get_clean();
}
add_shortcode('menushortcode', 'menu_loop');
莫回无