Title: Custom Fields &#8211; Add to array
Last modified: June 9, 2020

---

# Custom Fields – Add to array

 *  Resolved [johndoe01](https://wordpress.org/support/users/johndoe01/)
 * (@johndoe01)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-add-to-array/)
 * Greetings.
    Having the documentation on custom fields `https://wpadverts.com/
   documentation/custom-fields/` I have the following question.
 * If in the functions php the field gets added with this parameter:
 *     ```
       $form["field"][] = array(            
               "name" => "condition",
               "type" => "adverts_field_select",
               "order" => 29,
               "label" => "Condition",
               "is_required" => true,
               "validator" =>  array( 
                   array( "name" => "is_required" ),
               ),
               "options" => array(
                   array("value"=>"New","text"=>"New"),
                   array("value"=>"Used","text"=>"Used"),        
                   )
                );
       ```
   
 * How can i add a second item into the resulting array?
    Let me clarify: The result
   field comes into the form as array into the meta of the post with one item into
   the array. `'condition => 0 => "New"` The idea is add into the array a secondary
   key so i can use it to call such value in the meta to seize the field and extend
   an additional information piece like this
 *     ```
       array meta comes
       'condition'=>
           0 =>"New",
           1=>"star"
       ```
   
 * Am i missing something, or such meta does nnot allow secondary items on such 
   arrays?

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

 *  Thread Starter [johndoe01](https://wordpress.org/support/users/johndoe01/)
 * (@johndoe01)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-add-to-array/#post-12960777)
 * Nevermind. I did a workaround in the file (not in the functions), that served
   my purpose.
 * But in order to not let this thread go to waste: **How can i set a limit of characters
   on a text area?**
 * If you dear reader are asking how i did the workaraound… well i had to place 
   in the php file where will be displayed after the definition of the field:
 *     ```
       <?php
       <?php $my field = get_post_meta( $post_id, "the_field", false ); ?>
       if ($myfield[0]=="value1"){ $display="display-item1";}
       if ($myfield[0]=="value2"){ $display="display-item2";}   
       ... 
       ?> 
       ```
   
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-add-to-array/#post-12963578)
 * Hi,
    if you would like to show different option in the `<select>` and different
   value on the Ad details page then your options should look like this
 *     ```
         array("value"=>"display-item1","text"=>"New"),
         array("value"=>"display-item2","text"=>"Used"), 
       ```
   
 * Then in [adverts_add] you will see in the dropdown options “New” and “Used” but
   when viewing the Ad on the Ad details page the actual value will be either “display-
   item1” or “display-item2”.
 *  Thread Starter [johndoe01](https://wordpress.org/support/users/johndoe01/)
 * (@johndoe01)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-add-to-array/#post-12972704)
 * OK, even though it was not what i was looking for, I marl this as solved.

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

The topic ‘Custom Fields – Add to array’ is closed to new replies.

 * ![](https://ps.w.org/wpadverts/assets/icon-256x256.png?rev=2423472)
 * [WPAdverts - Classifieds Plugin](https://wordpress.org/plugins/wpadverts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpadverts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpadverts/)
 * [Active Topics](https://wordpress.org/support/plugin/wpadverts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpadverts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpadverts/reviews/)

## Tags

 * [character-limit](https://wordpress.org/support/topic-tag/character-limit/)
 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [values](https://wordpress.org/support/topic-tag/values/)

 * 3 replies
 * 2 participants
 * Last reply from: [johndoe01](https://wordpress.org/support/users/johndoe01/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-add-to-array/#post-12972704)
 * Status: resolved