ben-g
3/21/2017 - 3:08 PM

Hide field if there is no field content to show - BUT - also how to output content with specific html in it.

Hide field if there is no field content to show - BUT - also how to output content with specific html in it.

<!-- in this example, the fucntion checks the acf field to see if there is content.
If there is no content, the field is hidden.  If there is content (# of credit hours here)
the numbers are printed to screen with the word 'credits' and a pair of () -->

<?php if( get_sub_field('number_of_credits') ): ?>
    <span class="new-line-xs">(<?php the_sub_field('number_of_credits'); ?> credits)</span>
<?php endif; ?>

<!-- Note the () wrapped around the function "the_sub_field('number_of_credits');" along
with the word "credits".  -->