[英]output table in ACF that is in a repeater field
我正在显示一些表,并且我的表字段位于重复器字段中,因为我要彼此显示4个表,它们是彼此的一部分。
我正在查看代码,看到它返回的数组为4。
我看过以下代码: https : //wordpress.org/plugins/advanced-custom-fields-table-field/#screenshots但这仅在表位于普通字段而不是位于重复字段内时才起作用。 我无法获得任何信息。
我一直在尝试通过repeater字段循环,然后为该表运行代码,但这似乎不起作用,我从转储中得到的都是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;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.