Title: Special field shortcode
Last modified: July 20, 2017

---

# Special field shortcode

 *  Resolved [siddheshsj](https://wordpress.org/support/users/siddheshsj/)
 * (@siddheshsj)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/special-field-shortcode/)
 * I have created shortcode to display date on the form.
    But when i submit the 
   form “date” is not added to db table ‘wp-postmeta’. Can anyone please shed light
   on this why it is not get added, as its really urgent. Also if there is a way(
   code example) i can retrive and display the date using shortcode. Any help appreciated.
   I have added code below along with screenshot
 * Thank you in advance
 * **Code:**
    function shortcode_datepicker() { ?> <script> $(function() { $( “#
   datepicker1” ).datepicker({ }); }); </script> <input type = “text” id = “datepicker1″
   name=”datepicker1”>
 * <?php
    } add_shortcode( ‘custom_datepicker’, ‘shortcode_datepicker’ );
 * ![form field added using shortcode](https://ibb.co/fGi3x5)
    -  This topic was modified 8 years, 11 months ago by [siddheshsj](https://wordpress.org/support/users/siddheshsj/).

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

 *  anonymized-13171256
 * (@anonymized-13171256)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/special-field-shortcode/#post-9336547)
 * The field is not added to the database because the plugin doesn’t know what the
   shortcode does.
 * The next step is to append the new date to the other fields:
 *     ```
       /**
        * Add datepicker field to new testimonial post meta fields.
        * 
        * @param $new_meta array
        *
        * @return array
        */
       function custom_datepicker_add_meta( $new_meta ) {
         if ( isset( $_POST['datepicker1'] ) && $_POST['datepicker1'] ) {
           $new_meta['datepicker1'] = $_POST['datepicker1'];
         }
         return $new_meta;
       }
       add_filter( 'wpmtst_new_testimonial_meta', 'custom_datepicker_add_meta' );
       ```
   
 * You will need another shortcode to retrieve and display the date.
 * A simpler approach would be to use a plain text field and attach the datepicker
   to that.
 *     ```
       function my_datepicker( $atts ) {
         wp_enqueue_script( 'jquery-ui-datepicker' );
         ?>
         <script>
           jQuery(function () {
             // use your date field's id
             jQuery('#wpmtst_newdate').datepicker({})
           })
         </script>
         <?php
       }
       add_action( 'wpmtst_form_rendered', 'my_datepicker' );
       ```
   
 * That will make the date field available in the post meta box and the view editor
   so you can display it like any other field.
 *  Thread Starter [siddheshsj](https://wordpress.org/support/users/siddheshsj/)
 * (@siddheshsj)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/special-field-shortcode/#post-9339052)
 * [@chris](https://wordpress.org/support/users/chris/) Dillon
 * Thanks alot for your help. Much appreciated
 * First filter function which you gave is working perfectly fine.
    Can you please
   tell where to put function(hook:wpmtst_form_rendered) for display( i mean file
   wherein i can put) Also i was trying to display date stored in db on testimonial
   slider which is available by default along with rest of the fields. Do i need
   to write shortcode( consisting of wp_query) to fetch date for each postid everytime??
 *  anonymized-13171256
 * (@anonymized-13171256)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/special-field-shortcode/#post-9339416)
 * Let’s take a step back.
 * If you want to add a date field, you don’t need to use a shortcode field.
 * Instead, try this. Add a plain text field and attach datepicker to it using the
   second function above. That would go in your theme’s functions.php or an mu-plugin.
   Change “newdate” to your field name.
 * Then the date field will be available everywhere with the rest of the fields.
 * Does that make sense?
 *  Thread Starter [siddheshsj](https://wordpress.org/support/users/siddheshsj/)
 * (@siddheshsj)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/special-field-shortcode/#post-9339510)
 * Yes that sounds good . I dint think that way.
    You are awesome 🙂 Thank you sooo
   much

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

The topic ‘Special field shortcode’ is closed to new replies.

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

 * 4 replies
 * 2 participants
 * Last reply from: [siddheshsj](https://wordpress.org/support/users/siddheshsj/)
 * Last activity: [8 years, 11 months ago](https://wordpress.org/support/topic/special-field-shortcode/#post-9339510)
 * Status: resolved