Support

Account

Home Forums General Issues If statement not working Reply To: If statement not working

  • First off, the_field is used to echo a field’s contents, get_field is used to retrieve the fields data into into a variable, or in your case, can be used in an if statement. You also have a semi-colon after an if statement which is invalid and an empty else may had well just be removed. I’ve tied up your code a bit, give it a try.

    
    <?php 
    $dlMaterials = get_field('downloadable_material'); 
    if($dlMaterials) { ?>
        <div class="material">
            <h4>Supplemental Material:</h4>
            <a href="<?php echo $dlMaterials; ?>"><i class="icon-download-alt"></i> - Download Supplemental Material</a>
        </div>
    <?php } ?>
    
    
    <?php 
    $linksResources = get_field('links_and_resources'); 
    if($linksResources) { ?>
        <h4>Resources:</h4>
        <p><?php echo $linksResources; ?></p>
    <?php } ?>