Support

Account

Home Forums Front-end Issues Only Display data if True Reply To: Only Display data if True

  • Hi Beth.

    Well, if you validate it with a simple if, something like this:

    
    <?php if ( get_field('fireplace' ) ) : ?>
       // do something
       <?php the_field('fireplace'); ?>
    <?php endif; ?>
    

    This will show the field only if the field “fireplace” have something, this works with text fields and any field as well.

    Here the docs about it https://www.advancedcustomfields.com/resources/true-false/

    Like a extra point. To print the value of a custom field, you can use directly the function the_field('your_field_name') but if do you want to check or save the value of the field in a variable, you can use get_field('your_field_name')