Title: Conditional display based on Select
Last modified: August 30, 2016

---

# Conditional display based on Select

 *  Resolved [stevehtz](https://wordpress.org/support/users/stevehtz/)
 * (@stevehtz)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/conditional-display-based-on-select/)
 * Hi Matt,
 * Thanks for the great plug-in!
 * I would like to have the code in the template display only if a select field 
   contains a certain value. There are two types of members to display: Staff Members
   and Board Members. The user can choose from a select box which type that each
   Team Member is. In this sample code I am trying to display only the Team Members
   which are chosen as Board Members from the select box.
 * I know that the problem has something to do with the fact that select boxes output
   arrays, but I have not been able to figure it out beyond that.
 *     ```
       <?php
                 $loop = CFS()->get('members');
                 foreach ( $loop as $row ) {
                   if ($row['type'] == 'Board Member') {
                   ?>
                     <div class="member">
                       <div class="image">
                         <img src="<?php echo $row['avatar']; ?>" alt="">
                       </div>
                       <div class="member-label">
                         <h4><?php echo $row['name']; ?></h4>
                         <p><?php echo $row['position']; ?></p>
                       </div>
                     </div>
                   <?php
                   }
                 }
               ?>
       ```
   
 * Thank you so much for your help!
 * [https://wordpress.org/plugins/custom-field-suite/](https://wordpress.org/plugins/custom-field-suite/)

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

 *  [Srikanth Kamath](https://wordpress.org/support/users/tskamath/)
 * (@tskamath)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/conditional-display-based-on-select/#post-6335984)
 * try this..
 *     ```
       <select name="agama" id="agama">
       <?php
       $agamas = array('apple', 'banana', 'pineapple', 'orange', 'grapes');
       foreach ($agamas as $agama) {
             $selected = ($rows['agama'] === $agama) ? ' selected="selected"' : '';
       ?>
           <option value="apple"<?php echo $selected; ?>>apple</option>
       <?php
       }
       ?>
       </select>
       ```
   
 *  Plugin Author [Matt Gibbs](https://wordpress.org/support/users/mgibbs189/)
 * (@mgibbs189)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/conditional-display-based-on-select/#post-6336325)
 * Thanks [@tskamath](https://wordpress.org/support/users/tskamath/)

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

The topic ‘Conditional display based on Select’ 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/)
 * [select](https://wordpress.org/support/topic-tag/select/)

 * 2 replies
 * 3 participants
 * Last reply from: [Matt Gibbs](https://wordpress.org/support/users/mgibbs189/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/conditional-display-based-on-select/#post-6336325)
 * Status: resolved