Support

Account

Home Forums General Issues Field values based on conditional statement not showing in loop

Helping

Field values based on conditional statement not showing in loop

  • I have a nested group that contains a standard field and then two additional fields based on what radio button is selected in the back-end. There are three options and when the user selects on, two fields appear.

    In the loop, everything works except the fields that are based on what radio button is selected. The condition is working because I have a different icon for each option and the correct icon is showing. But the field values are not.

    In my code below, the fields that aren’t showing are ‘file’ and ‘file_size’

    I hope someone can help! Thanks!

    Here is my code:

    <?php if( have_rows('exploring_dignity_files') ): ?>
    	<div id="exploring_dignity_files" class="accordion">
    		<h4>Exploring Dignity</h4>
    			<div>
    				<div class="teaching_resources_content-wrap">
    					<div class="teaching_resources_content-wrap-inner">
    						<?php while( have_rows('exploring_dignity_files') ): the_row();?>					
    							<?php if( have_rows('single_resource') ): ?>
    								<?php while( have_rows('single_resource') ): the_row();?>					
    									<div class="single-teaching-resource-file">
    										<?php if( get_sub_field('resource_type') == 'PDF' ): ?>
    										<div class="resource-file-left">
    											<img src="/wp-content/themes/global-dignity/svg/pdf-icon.svg" width="93px" height="auto" />
    											<?php the_sub_field('file_size');?>
    
    											<a href="<?php the_sub_field('file');?>">Download PDF</a>
    										</div>
    										<?php endif;?>	
    
    										<?php if( get_sub_field('resource_type') == 'Link' ): ?>
    										<div class="resource-file-left">
    											<img src="/wp-content/themes/global-dignity/svg/video_link.svg" width="93px" height="auto" />
    											<a href="<?php the_sub_field('file');?>">view video</a>
    										</div>
    										<?php endif;?>	
    
    									
    										<?php if( get_sub_field('resource_type') == 'Video' ): ?>
    										<div class="resource-file-left">
    											<img src="/wp-content/themes/global-dignity/svg/link_icon.svg" width="93px" height="auto" />
    											<a href="<?php the_sub_field('file');?>">visit page</a>
    										</div>
    										<?php endif;?>	
    											
    										<div class="resource-file-right">
    											<h4><?php the_sub_field('resource_name');?></h4>
    											<?php the_sub_field('text');?>
    
    											Suggested Use
    
    											<?php the_sub_field('suggested_use');?>
    
    										</div>
    									</div>
    								<?php endwhile;?>
    							<?php endif;?>										
    						<?php endwhile;?>
    					</div>
    				</div>
    			</div>
    	</div>
    <?php endif;?>	
    
  • Problem solved. I was missing a group.

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

The topic ‘Field values based on conditional statement not showing in loop’ is closed to new replies.