Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom field set that is look to display like so:

<p><strong>Lease Rate:</strong>
        <?php the_field('lease_rate'); ?>
      </p>
      <p> <strong>NNN Expenses:</strong>
        <?php the_field('nnn'); ?>
      </p>
      <p> <strong>Monthly Rent:</strong>
        <?php the_field('rent'); ?>
      </p>

       <p> <strong>Site Area:</strong>
        <?php the_field('site_area'); ?>
      </p>
      <p><strong>Sale Price:</strong>
      <?php the_field('building_size'); ?></p>
      <p><strong>Building Size:</strong>
      <?php the_field('Address'); ?></p>
      <p><strong>Contact Name:</strong>
      <?php the_field('contact_name'); ?></p>
      <p><strong>Phone Number:</strong>
      <?php the_field('phone_number'); ?></p>

I need to change it so that:
IF the field is filled in, THEN the title shows up.

For example, if the_field lease_rate has a value then the paragraph "Lease Rate" shows up.

I was thinking some kind of if statement then echoing the p?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You can use the ACF API's get_field to test for the existence of data:

if( $lease_rate = get_field('lease_rate') ){
    ?>
    <p><strong>Lease Rate:</strong>
        <?php echo $lease_rate; ?>
    </p>
    <?php
}
share|improve this answer
    
wow, yup, that easy huh? thank you very much!!!! –  user31344 Nov 20 '13 at 17:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.