Title: Conditional output
Last modified: August 30, 2016

---

# Conditional output

 *  Resolved [chzumbrunnen](https://wordpress.org/support/users/chzumbrunnen/)
 * (@chzumbrunnen)
 * [11 years ago](https://wordpress.org/support/topic/conditional-output-1/)
 * What would be the best practices to output some blocks only if the custom field(
   that I want to output within a HTML block) is not empty?
 * Example:
 *     ```
       <div class="content-col content-col-4 last">
        <div class="productprice"><?php echo CFS()->get('productprice'); ?></div>
        <p class="priceoption"><?php echo CFS()->get('priceoption'); ?></p>
        <br />
         <a class="button align-right" href="<?php echo CFS()->get('order_url'); ?>"><?php echo CFS()->get('btn_text'); ?></a><br />
        </div>
       ```
   
 * If productprice is empty the whole div-block should not be outputted.
 * So I guess, I could do something like
 *     ```
       <?php
       if (!empty(CFS()->get('productprice'))) {
       ?>
             <div class="content-col content-col-4 last">
               <div class="productprice"><?php echo CFS()->get('productprice'); ?></div>
               <p class="priceoption"><?php echo CFS()->get('priceoption'); ?></p>
               <br />
               <a class="button align-right" href="<?php echo CFS()->get('order_url'); ?>"><?php echo CFS()->get('btn_text'); ?></a><br />
             </div> <!-- .second-col -->
       <?php
       }
       ?>
       ```
   
 * But would this considered the right way to do it?
 * [https://wordpress.org/plugins/custom-field-suite/](https://wordpress.org/plugins/custom-field-suite/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [chzumbrunnen](https://wordpress.org/support/users/chzumbrunnen/)
 * (@chzumbrunnen)
 * [11 years ago](https://wordpress.org/support/topic/conditional-output-1/#post-6209416)
 * It works. I guess it’s ok.

Viewing 1 replies (of 1 total)

The topic ‘Conditional output’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-field-suite.svg)
 * [Custom Field Suite](https://wordpress.org/plugins/custom-field-suite/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-field-suite/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-field-suite/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-field-suite/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-field-suite/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [chzumbrunnen](https://wordpress.org/support/users/chzumbrunnen/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/conditional-output-1/#post-6209416)
 * Status: resolved