Wordpress Acf中继器更改类中的Acf复选框
我想在选择中继器内的复选框时更改类。我使用Wordpress Acf中继器更改类中的Acf复选框,wordpress,advanced-custom-fields,Wordpress,Advanced Custom Fields,我想在选择中继器内的复选框时更改类。我使用开关盒执行此操作,但我无法在之外的时获取checkboks值。当正确时,如何从中取出复选框数组 ACF $checkboxarray = get_field('sy_color'); 代码: <div class="loop solution-include-pages d-flex"> <?php if (have_rows('support_you')) { $checkboxarray = ge
开关盒执行此操作
,但我无法在之外的时获取checkboks值。当
正确时,如何从中取出复选框数组
ACF
$checkboxarray = get_field('sy_color');
代码:
<div class="loop solution-include-pages d-flex">
<?php
if (have_rows('support_you')) {
$checkboxarray = get_field('sy_color');
foreach ($checkboxarray as $value) {
switch ($value) {
case 'red':
$class = 'rose-c';
break;
case 'green':
$class = 'green-c';
break;
case 'blueberry':
$class = 'blueberry-c';
break;
}
while (have_rows('support_you')) {
the_row();
$sy_img = get_sub_field('sy_img');
$sol_img = wp_get_attachment_image_src( $sy_img, 'full', true );
$sy_header = get_sub_field('sy_header');
$sy_content = get_sub_field('sy_content');
$sy_link = get_sub_field('sy_link');
$sy_color = get_sub_field('sy_color');
?>
<div class="sol-item d-flex flex-direction">
<div class="sol-item-img">
<img src="<?php echo $sol_img[0];?>" class="img-responsive" alt="">
</div>
<div class="sol-content">
<div class="sol-content-header <?php echo $class; ?>">
<?php echo $sy_header; ?>
</div>
<div class="sol-content-text">
<?php echo $sy_content; ?>
</div>
<a href="<?php echo $sy_link;?>" class="bluberry-btn item-center">Learn more</a>
</div>
</div>
<?php
}
}
}
?>
</div>
“class=”img responsive“alt=”“>
如果您不在_行()内,则无法获取子字段。如果您使用
$support_you = get_field('support_you');
它将返回一个数组,所有子字段都将返回到该数组中,您可以通过这种方式访问它
echo '<pre>', print_r( $support_you, 1 ), '</pre>';
echo'',打印($support\u you,1),'';
如果该复选框位于中继器内,则在输出我计算出的所有数组并正确设置条件后,您应该使用获取子字段()
而不是获取子字段()
谢谢您的帮助