I've got a Custom Post called you "youtube" which has three ACF custom fields, one of which is a Checkbox (color) that can have three values;
red : Red
green : Green
blue : Blue
I've created a post array using this code:
$youtube_ids = get_posts(
array(
'post_type' => 'youtube',
'post_status' => 'publish',
'posts_per_page' => - 1,
'fields' => 'ids',
) );
For each post I want to see if a certain checkbox value has been set.
Something along the lines of this pseudo code:
foreach youtube_ids value
if Color == red
do some html stuff
endif
endforeach
I've revisited this and my youtube post now contains the three fields:
registration (text)
tubeid (text)
section (checkbox with 4 values)
This is as far as I've got with the code and this returns the tubeid
<?php
$youtube = get_posts(
array(
'post_type' => 'youtube',
'post_status' => 'publish',
'posts_per_page' => - 1,
'fields' => 'ids',
));
// IF SUCCESSFUL ...
if($youtube)
{
// ITERATE OVER THE POSTS
foreach($youtube as $post) {
$value = get_field('tubeid', $post);
echo $value . '<br>';
}
}
?>
I'm afraid I still cant see how to get the checkbox values for "section"