Hi
I really hope there is someone who can help me.
I have created a website in WordPress, and I have used the plugin Advanced Custom Fields Pro (ACF).
I have created a checkbox which is a sub-field for a repeater-field.
What I have been trying to do is to show some content if a certain value is checked. In the example below it is “check”.
Here is my code:
$options = get_sub_field('options');
if( $options && in_array('check', $options) ) {
echo "Some content";
} else {
var_dump($options);
}
The ‘var_dump($options);’ show this: “bool(false)”.
I have written the code shown on this page (Conditional logic): https://www.advancedcustomfields.com/resources/checkbox/
The “Return Value” for the checkbox-field is ‘Value’.
It would be a huge help if someone have some time to give me a good advice.
Thanks in advance!
Hi John
The code below must be run when the checkbox option is set to “check”.
<?php
// Get repeater value
$repeater = get_field('options');
// Obtain list of columns
foreach ($repeater as $key => $row) {
$the_logo[$key] = $row['logo'];
$the_bonus[$key] = $row['bonus'];
$the_link[$key] = $row['link'];
}
array_multisort( $repeater, SORT_DESC );
foreach( $repeater as $row ) {
} ?>