Support

Account

Home Forums Backend Issues (wp-admin) Conditional logic with multiple if(get_field())

Helping

Conditional logic with multiple if(get_field())

  • Trying to get this conditional statement to work and can’t figure out why it won’t:

    <?php if(get_field('signups')) || (get_field('dropbox')) || (get_field('agreement')) || (get_field('notes')) : ?>
    
    		<div class="parent-forms sidebar-box">
    	
    			<h3>Forms & Downloads</h3>
    			<ul class="sidebar-menu">				
    				<?php if(get_field('signups')): ?><li><a class="form-button" href="<?php the_field('signups') ?>">Audition Sign-Ups</a></li><?php endif ?>
    
    				<?php if(get_field('dropbox')): ?><li><a class="form-button" target="_blank" href="<?php the_field('dropbox'); ?>">Dropbox</a></li><?php endif ?>
    
    				<?php if(get_field('agreement')): ?><li><a class="form-button" target="_blank" href="<?php the_field('agreement'); ?>">Parent Agreement</a></li><?php endif ?>
    
    				<?php if(get_field('notes')): ?><li><a class="form-button" href="<?php the_field('notes'); ?>">Director's Notes</a></li><?php endif ?>
    			</ul>
    		</div>
    
    		<?php endif; ?>
  • Hi @ddressel,

    Thanks for the post.

    I don’t think you need the parent conditional block since you are also checking if the value of the field is empty within the class.

    From the logic that you have set up, the class will be called if any of four fields is true and thus the fields should show up.

    I would recommend you debug all the values from the get_field() calls to check if the expected data is getting returned.

    Please have a look at our debugging tutorial here: http://www.advancedcustomfields.com/resources/debug/

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

You must be logged in to reply to this topic.