I'm trying to retrieve the values of checkboxes in a custom post type.
My complete function:
function getTeam() {
global $post;
$team = new WP_Query();
$team->query('post_type=coaches');
$workshops = get_field('workshops');
if ($team->found_posts > 0) {
echo '<ul>';
while ($team->have_posts()) {
$team->the_post();
$listTeam = '<li>';
$listTeam .= '<a href="#" class="js-modal">';
$listTeam .= '<figure class="profile-img">';
$listTeam .= '<img src="' . get_field('profile-image') . '" alt="">';
$listTeam .= '<figcaption><span>Bekijk profiel</span></figcaption>';
$listTeam .= '</figure>';
$listTeam .= '</a>';
$listTeam .= '<article class="profile-bio">';
$listTeam .= '<div class="details">';
$listTeam .= '<h3>' . get_field('name') . '</h3>';
$listTeam .= '<h4>Workshop(s)</h4>';
$listTeam .= '<ul class="workshops">';
if ($workshops) {
foreach($workshops as $workshop) {
$listTeam .= '<li>' . $workshop . '</li>';
}
}
$listTeam .= '</ul>';
$listTeam .= '</div>';
$listTeam .= '<p>' . get_field('biography') . '</p>';
$listTeam .= '</article>';
$listTeam .= '</li>';
echo $listTeam;
}
echo '</ul>';
wp_reset_postdata();
} else {
echo '<p>No team members found</p>';
}
var_dump($workshops, $workshop);
}
I created the foreach loop with the help of the ACF checkbox documentation and as far as I know there are no errors in that.
But I get for $workshops bool(false)
and for $workshop NULL
returned.
How can I troubleshoot this the best to see where this goes wrong?
I tried http://php.net/manual/en/language.types.boolean.php but that doesn't say anything (yet) to me :)