Support » Plugin: Meta Box - WordPress Custom Fields Framework » Frontend datetime picker

  • Resolved snuffybg


    Is it possible to include in frontend the datetime picker js css since its only for backend ?

    I am using wc marketplace and since its not supporting metabox fields (yet) i used some of theyr actions to add the field in frontend.
    This is my metafield:

    add_filter( 'rwmb_meta_boxes', 'theme_meta_boxes' );
    function theme_meta_boxes( $meta_boxes ) {
        $meta_boxes[] = array(
        'title'  => __( 'Event Information', 'theme-slug' ),
        'post_types' => 'product',
        'context'    => 'normal',
        'priority'   => 'high',    
        'fields' => array(
            'id'        => 'event_date',
            'name'   => __( 'Event Date', 'theme-slug' ),
            'type'    => 'datetime',
            'js_options' => array(
                'dateFormat'      => 'dd-mm-yy',
                'showTimepicker'  => true,        
                'stepMinute'      => 15,
            'save_format' => 'd-m-Y H:i:s',
            'timestamp'  => true,
        return $meta_boxes;

    In frontend i add the following actions in functions.php to get my field :

    function add_custom_product_data_tabs( $tabs ) {
      $tabs['advanced'] = array(
          'label'    => __( 'Event date', 'your-text-domain' ),
          'target'   => 'event_date_tab',
          'class'    => array(),
          'priority' => 100,
      return $tabs;
    add_filter( 'wcmp_product_data_tabs', 'add_custom_product_data_tabs' );
    function add_custom_product_data_content( $pro_class_obj, $product, $post ) {
        $get_value = get_post_meta($post->ID,'event_date');
       <div role="tabpanel" class="tab-pane fade" id="event_date_tab">
           <div class="row-padding">
               <div class="form-group">
                   <label class="control-label col-sm-3 col-md-3">Event Date</label>
                   <div class="col-md-6 col-sm-9">
                        <input type="text" name="event_date" class="form-control"  value="<?php echo $get_value[0] ?>" />
    add_action( 'wcmp_product_tabs_content', 'add_custom_product_data_content', 10, 3 );
    function save_custom_product_data( $product, $post_data ) {
      if( isset($post_data['post_ID']) && isset($post_data['event_date'])){
          update_post_meta( absint( $post_data['post_ID'] ), 'event_date', $post_data['event_date']);
    add_action( 'wcmp_process_product_object', 'save_custom_product_data', 10, 2 );

    So is it possible to make the field works the sameway as in backend ? Since i want to keep the format of the date and time and stepMinute to be per 15.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Anh Tran


    Hi @snuffybg,

    Not sure if you’re the same person who opened a similar topic in the support forum.

    In this situation, you manually output the field and handle the saving process. You don’t use our MB Frontend Submission extension to output a meta box (and fields) to the front end. That means you have to handle everything on the front end.

    So, if you want to make the date picker works in the front end, you might need to enqueue the necessary scripts and styles for it. Take a look at our plugin source code to have an idea how to do that.

    Another thing is that the datepicker script is not registered for the front end. You have to do that manually. Here is an example I take from the MB Frontend Submission extension.

    I hope my answer helps you a little bit.



    The theme is EduPro and I have the problem that I visualize the times with the American system am and pm and I can’t put the time in the Italian format.
    Here’s where it looks bad
    How can I do ?

    Plugin Author Anh Tran


    Hi @giorgioangelini1984 ,

    Let me check with that theme to see what’s the problem. If I find anything, I’ll contact the theme author to update it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.