Support

Account

Home Forums General Issues Hide field if empty

Helping

Hide field if empty

  • Is there a way to hide a field on the front end if it is blank on the back end?

  • Try this code, Might be it will be work for you.
    <?php
    $value = get_field(‘your_field_name’); // retrieve the field value
    if ( ! empty($value) ) : // check if it’s not empty
    ?>
    <p><?php echo esc_html($value); ?></p> // then output it (or your custom markup)
    <?php
    endif;
    ?>

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

You must be logged in to reply to this topic.