Title: Adding Select Field To the Loop
Last modified: August 30, 2016

---

# Adding Select Field To the Loop

 *  Resolved [914Digital](https://wordpress.org/support/users/soulstatic/)
 * (@soulstatic)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/adding-select-field-to-the-loop/)
 * Hey,
    I’m trying to add a single select field to the loop. Not sure how to do
   it.
 * This is what I have. I know it’s wrong.
 * (BTW, Great plugin!!)
 *     ```
       $fields = CFS()->get('resources');
       	                     foreach ($fields as $field) { ?>
   
        <?php .$values = CFS()->get('resource_type');
       foreach ($values as $value => $label) {
           echo '<td>' . $value . '</td>';
       }
       ?>
       	                     <?php echo '<td><a href="'.$field['resource_link'].'">'.$field['resource_title'].'</a></td></tr>'; ?>
   
       	                  <?php   }  ?>
       ```
   
 * [https://wordpress.org/plugins/custom-field-suite/](https://wordpress.org/plugins/custom-field-suite/)

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

 *  Plugin Author [Matt Gibbs](https://wordpress.org/support/users/mgibbs189/)
 * (@mgibbs189)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/adding-select-field-to-the-loop/#post-6604774)
 * Use var_dump on $fields to find out how the data is being stored. If “resources”
   is a loop, then all field values are within it. You don’t need separate get()
   calls.
 *     ```
       var_dump( $fields );
       ```
   
 *  Thread Starter [914Digital](https://wordpress.org/support/users/soulstatic/)
 * (@soulstatic)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/adding-select-field-to-the-loop/#post-6604777)
 * I’m not sure I follow. How would I call the field then?
 *  Thread Starter [914Digital](https://wordpress.org/support/users/soulstatic/)
 * (@soulstatic)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/adding-select-field-to-the-loop/#post-6604779)
 * OK. I just did the var_dump. Basically, I want to be able to echo array(1)
 *  Thread Starter [914Digital](https://wordpress.org/support/users/soulstatic/)
 * (@soulstatic)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/adding-select-field-to-the-loop/#post-6604782)
 * Hmm. I didn’t think this issue was resolved.
 *  [mrspabs](https://wordpress.org/support/users/mrspabs/)
 * (@mrspabs)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/adding-select-field-to-the-loop/#post-6604809)
 * Just posting the resolution here for anyone else who needs it.
 *     ```
       <?php
       /*
           A loop field named "gallery" with sub-fields "slide_title", "upload" and a select called file_type.
       */
       $fields = CFS()->get('gallery');
       foreach ($fields as $field) {
           echo $field['slide_title'];
           echo $field['upload'];
           echo current($field[file_type]);
       }
       ?>
       ```
   
 * Since the select field “file_type” returns an array, using current will allow
   you to display the first item in the array.
 * This solution only works for a select box where only one item can be chosen.
 *  [ddangelillo](https://wordpress.org/support/users/ddangelillo/)
 * (@ddangelillo)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/adding-select-field-to-the-loop/#post-6604856)
 * Thanks @ mrspabs!
    Your solution worked for me!

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

The topic ‘Adding Select Field To the 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/)

 * 6 replies
 * 4 participants
 * Last reply from: [ddangelillo](https://wordpress.org/support/users/ddangelillo/)
 * Last activity: [10 years, 7 months ago](https://wordpress.org/support/topic/adding-select-field-to-the-loop/#post-6604856)
 * Status: resolved