Support

Account

Home Forums Front-end Issues Basic "True/False inside Group" question

Solved

Basic "True/False inside Group" question

  • Hi all,

    Just when I think I’m becoming a clever person and have figured it all out, I run into what I’m hoping is just me being tired and overseeing something totally basic, but…

    I have a True/False field and a basic Text field, inside a Group field. So, it’s just a basic “if it’s set to True, then show my code, along with the Text field content.

    Can someone please point out, the stupid mistake I’ve made, so I can move on. I just can’t see it.

    Many thanks in advance.

    
    <?php
    	$theGroup = get_field('group_field_name');
    	if( $theGroup ): ?>
    
    	<?php if ( get_sub_field( 'truefalse_field_name' ) ): ?>
    		<div class="class_name"><?php echo get_sub_field('text_field_name'); ?></div>
    	<?php else: ?>
    	<?php endif; ?>
    
    <?php endif; ?>
    
  • You don’t have a have_rows() loop, so you can’t use get_sub_field()

    
    <?php
    	$theGroup = get_field('group_field_name');
    	if( $theGroup ): ?>
    
    	<?php if ( $theGroup['truefalse_field_name'] ): ?>
    		<div class="class_name"><?php echo $theGroup['text_field_name']; ?></div>
    	<?php else: ?>
    	<?php endif; ?>
    
    <?php endif; ?>
    
  • As always, John, your help is prompt, instructive and never condescending for us dummies. Thank you, yet again.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Basic "True/False inside Group" question’ is closed to new replies.