WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields
[resolved] Condition if field is blank (2 posts)

  1. markyeoj
    Member
    Posted 1 year ago #

    Hi, I am displaying the the values of my custom fields with labels, like this.

    <h5 class="semibold">Preperation Time</h5>
    <?php the_field('prep_time'); ?>

    The problem is the label will always be there even if the field has no value. Now I want to make a condition something like this

    if field_name has value{
    <h5 class="semibold">Preperation Time</h5>
    <?php the_field('prep_time'); ?>
    }

    how can I do that?, thanks.

    http://wordpress.org/extend/plugins/advanced-custom-fields/

  2. markyeoj
    Member
    Posted 1 year ago #

    done -- I used this code

    <?php if (get_field('cook_time') && get_field('cook_time') != "") { ?>
    <div class="left recipe-detail">
    <h5 class="semibold">Cook Time</h5>
    <?php the_field('cook_time'); ?>
    </div>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic