[英]ACF - get checkbox values inside flexible content field
Have been going around and around with this and can't make it work - probably something very simple but I've got no hair left - can anyone help me? 一直在进行此操作并且无法使其正常工作-可能很简单,但是我没有头发-有人可以帮助我吗?
<?php
if( have_rows('page_content') ):
while ( have_rows('page_content') ) : the_row();
if( get_row_layout() == 'specs' ):
// check if the nested repeater field has rows of data
if( get_sub_field('objectives') ):
echo '<ul>';
$field = get_field_object('objectives');
$value = $field['value'];
$choices = $field['choices'];
// loop through the rows of data
foreach( $value as $v):
echo '<li>'.$choices.'</li>';
endforeach;
echo '</ul>';
endif;
endif;
endwhile;
endif;
?>
Thanks in advance. 提前致谢。
Can you try with the Key of ACF field like this, 您可以像这样尝试使用ACF的密钥字段吗?
$field_key = "field_5039a99716d1d";
$field = get_field_object($field_key);
https://www.advancedcustomfields.com/resources/get_field_object/ https://www.advancedcustomfields.com/resources/get_field_object/
Working now ... thanks to the great support team at ACF. 现在正在工作...感谢ACF的强大支持团队。 I was missing the [$v] after .$choices.
..choices之后我错过了[$ v]。 Working code below:
下面的工作代码:
<?php
if( have_rows('page_content') ):
while ( have_rows('page_content') ) : the_row();
if( get_row_layout() == 'specs' ):
// check if the nested repeater field has rows of data
if( get_sub_field('objectives') ):
echo '<ul>';
$field = get_field_object('objectives');
$value = $field['value'];
$choices = $field['choices'];
// loop through the rows of data
foreach( $value as $v):
echo '<li>'.$choices.'</li>';
endforeach;
echo '</ul>';
endif;
endif;
endwhile;
endif;
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.