Home › Forums › Front-end Issues › Checkbox within a group
I have a group which works great. However, I want to add a checkbox inside of it which I’ve done.
I’ve got;
<?php
$career_one_group = get_sub_field('career_one_group');
if( $career_one_group ):
?>
<?php if ( get_sub_field( 'show_careers_information' ) == 'Yes' ): ?>
Show
<?php endif; ?>
<?php endif; ?>
Nothing is showing up and not 100% sure why — is it possible?
is show_careers_information
a sub field of career_one_group
It’s inside the group if that’s what you mean?
I’ve attached URL (image) of back-end – https://ibb.co/7NqH5KP
A group field works like a repeater field, you either need to use a have+_rows() loop or get the group field and use the array. You should look at the documentation for the group field, if you have questions let me know. https://www.advancedcustomfields.com/resources/group/
Hi John,
Thanks, I cracked it with this (for other people’s reference)
<?php
$career_one_group = get_sub_field('career_one_group');
if( $career_one_group ):
?>
<?php if( have_rows('career_one_group') ): ?>
<?php while( have_rows('career_one_group') ): the_row();
$show_careers_information = get_sub_field('show_careers_information');
$show_local_vacancy = get_sub_field('show_local_vacancy');
$show_day_in_the_life_of_a = get_sub_field('show_day_in_the_life_of_a');
$show_what_employers_want_transferable_skills = get_sub_field('show_what_employers_want_transferable_skills');
$show_timeline = get_sub_field('show_timeline');
?>
<!-- Start Loop -->
<?php if( $show_careers_information ): ?>
<?php endif; ?>
<!-- End Loop -->
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
<?php endif; ?>
The topic ‘Checkbox within a group’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.