Title: Types Checkboxes Array
Last modified: August 30, 2016

---

# Types Checkboxes Array

 *  [iamfablaz](https://wordpress.org/support/users/fabriziolazzeretti/)
 * (@fabriziolazzeretti)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/types-checkboxes-array/)
 * Hi all,
    since i’ve struggling with Types Checkboxes, and custom display the 
   content of it i decided to study a bit of php and bypass le limit of not having
   the visual designer from Types (Views). My problem was i have a group wich contains
   checkboxes field (note i stated checkboxes with an “s” so a group of checkboxes
   and not the single field), therefore the array gave me always 1 item, using php
   function types_render_field(…), an output of values separated by commas. So my
   solution was to use php to convert back this output to a valid array to play 
   with. Here is the code:
 * //starting query
    global $wp_query; //get current post id $postid = $wp_query-
   >post->ID; //store the array from “checkboxes-field-slug” in the variable $sea
   $sea = types_render_field( “checkboxes-field-slug”, array(“output” => “raw”) );//
   explode and convert the variable $sea to a new array using “,” as separator $
   myarray = explode(“,”, $sea); //Use the new array to whatever i need to foreach(
   $myarray as $item){ echo ‘<div>’.$item.'</div>’;} }
 * Just one thing to be aware of:
    for each checkbox, the value i store is not 1
   or 0, instead i use a plain word or group of words serparate by “-” (ex. “Free
   room service” will be stored manually as “free-room-service”)
 * This function is used as a shortcode and works only on posts having a certain
   category.
 * I’ve searching for days and didn’t notice i had the solution under my nose!
    
   Hope this helps many of you.
 * Please feel free to improve the code and post it back here. Thanks.
 * [https://wordpress.org/plugins/types/](https://wordpress.org/plugins/types/)

The topic ‘Types Checkboxes Array’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/types_ced1d3.svg)
 * [Toolset Types - Custom Post Types, Custom Fields and Taxonomies](https://wordpress.org/plugins/types/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/types/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/types/)
 * [Active Topics](https://wordpress.org/support/plugin/types/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/types/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/types/reviews/)

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [checkboxes](https://wordpress.org/support/topic-tag/checkboxes/)
 * [custom function](https://wordpress.org/support/topic-tag/custom-function/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)

 * 0 replies
 * 1 participant
 * Last reply from: [iamfablaz](https://wordpress.org/support/users/fabriziolazzeretti/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/types-checkboxes-array/)
 * Status: not resolved