Support

Account

Home Forums Front-end Issues Checkbox within a group

Solving

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; ?>	
Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Checkbox within a group’ is closed to new replies.