Title: Conditional inside repeatable (loop)
Last modified: August 21, 2016

---

# Conditional inside repeatable (loop)

 *  Resolved [lagunas](https://wordpress.org/support/users/lagunas/)
 * (@lagunas)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/conditional-inside-repeatable-loop/)
 * Hi, great plugin!
 * I have a simple question: How would you use a conditional if you want something
   to show only if a field inside a repeatable loop has been filled?
 * A similar question has been answered here: [http://uproot.us/forums/questions/942/conditional](http://uproot.us/forums/questions/942/conditional)
 * But I can’t make it work with the code provided to show a field that is inside
   a loop.
 * Thank you very much!
 * [http://wordpress.org/extend/plugins/custom-field-suite/](http://wordpress.org/extend/plugins/custom-field-suite/)

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

 *  Plugin Author [Matt Gibbs](https://wordpress.org/support/users/mgibbs189/)
 * (@mgibbs189)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/conditional-inside-repeatable-loop/#post-3668527)
 * Loops are simply PHP arrays. If you have a loop field called “gallery” with sub-
   fields “caption” and “image”, then…
 * _[ Moderator note: try to use backticks instead of pre for code. ]_
 *     ```
       $loop_field = $cfs->get('gallery');
       foreach ($loop_field as $row) {
           // show image and caption ONLY if the image exists
           if (!empty($row['image'])) {
               echo ' IMAGE: ' . $row['image'];
               echo ' CAPTION: ' . $row['caption'];
           }
       }
       ```
   
 * That should give you plenty to work with.
 * Cheers,
    Matt
 *  Thread Starter [lagunas](https://wordpress.org/support/users/lagunas/)
 * (@lagunas)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/conditional-inside-repeatable-loop/#post-3668543)
 * Great!
    I thought I tried that. Maybe I was missing something.
 * Works perfectly, thank you!
    And thanks again for the great plugin!!

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

The topic ‘Conditional inside repeatable (loop)’ 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/)

## Tags

 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [field](https://wordpress.org/support/topic-tag/field/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [repeatable](https://wordpress.org/support/topic-tag/repeatable/)

 * 2 replies
 * 2 participants
 * Last reply from: [lagunas](https://wordpress.org/support/users/lagunas/)
 * Last activity: [13 years, 1 month ago](https://wordpress.org/support/topic/conditional-inside-repeatable-loop/#post-3668543)
 * Status: resolved