ACF 中的输出表位于转发器字段中



我正在对表进行一些显示,我的表字段位于中继器字段中,因为我想显示彼此相邻的 4 个表,它们是彼此的一部分。

我正在查看代码,看到它返回一个 4 的数组。

我看过这段代码:https://wordpress.org/plugins/advanced-custom-fields-table-field/#screenshots 但这似乎仅在表位于正常字段中而不是在中继器字段中时才有效。我无法从中获取任何信息。

我一直在尝试遍历中继器字段,然后运行表的代码,但这似乎不起作用,我从转储中得到的只是NULL.

if( have_rows($table) ): // loop through the rows of data 
while ( have_rows($table) ) : the_row();
var_dump($table['information_table']) 
endwhile; 
else : 
// no rows found 
endif;

有人对如何从中继器字段显示表格有任何提示吗?

谢谢。

转发器表
插件作者提供了以下代码示例: 不知道你错过了什么。尝试不使用 $table 变量,仅使用字段名称。验证您使用的sub_field名称是否正确。仔细检查您是否将数据保存在数据库中。看起来你应该使用sub_field('information_table'(而不是$table['information_table']

// check if the repeater field has rows of data
if( have_rows('repeater_field_name') ):
// loop through the rows of data
while ( have_rows('repeater_field_name') ) : the_row();
// get a sub field value (table field)
$table = sub_field('sub_field_name');
// use the “Output Table HTML” code with $table   
endwhile;
else :
// no rows found
endif;

最新更新