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

  1. markyeoj
    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.


  2. markyeoj
    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'); ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Advanced Custom Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic