If Custom Field is empty don’t display div

Try this:

<?php 
     $business_services = get_field( "services_for_businesses" ); 
     //etc...
?>

<div class="section-title">Services for Individuals</div>

    <div class="section-text">
        <?php the_field('services_for_individuals') ?>
    </div>

    <?php if ( $business_services ) : ?>

    <div class="section-title-business">Services for Businesses</div>    
        <div class="section-text">
            <?php echo $business_services; ?>
        </div>
    </div>

    <?php endif; ?>

</div>

Further abstract the code to meet your needs if you have more than one field to show or hide.

Leave a Comment

tech