0

Hello everybody I tried to follow many post and guides but with results not according to my needs. I need a simple meta box that catches a data timestamp like the standard one in Wordpress posts or pages. I've created a metabox but the

type="date"
attribute to HTML form prints a datepicker in english format and I need to translate it in italian. The standard date picker from Wordpress is allready translated in Italian... I don't want to install a plugin because I've created a plugin for custom post type on my own and I'm updating the code with these new functionalities. I'm going to paste my code below. Thanks , in advance.

<?php 

function arrivo_meta_box_markup($object)
{
    wp_nonce_field(basename(__FILE__), "meta-box-nonce");

    ?>
        <div>
            <label for="arrivo_meta_box">Data arrivo in negozio</label>
            <input name="arrivo_meta_box" type="date" value="<?php echo get_post_meta($object->ID, "arrivo_meta_box", true); ?>">
        </div>
    <?php  
}
  • The output of type="date" is handled by the browser, as it's a native control. So it should reflect the user's browser language. – Jacob Peattie Apr 7 '18 at 13:31
0

No ones was answering so i installed this plugin MetaBox.io

and I've generated this code below that worsk very vell.

function arrivo_metabox( $meta_boxes ) {
  $prefix = 'arrivo-';

  $meta_boxes[] = array(
    'id' => 'arrivo',
    'title' => esc_html__( 'Data di arrivo in negozio', 'porto-child' ),
    'post_types' => array( 'riparazioni' ),
    'context' => 'side',
    'priority' => 'default',
    'autosave' => false,
    'fields' => array(
      array(
        'id' => $prefix . 'data_arrivo',
        'type' => 'date',
        'name' => esc_html__( 'Data arrivo in negozio', 'porto-child' ),
        'js_options' => array(
          'dateFormat' => 'dd/mm/yy',
          'dayNames' => '[ "Domenica", "Lunedì "Martedi", "Mercoledì", "Giovedì", "Venerdì", "Sabato" ]',
        ),
        'class' => 'data-arrivo',
      ),
    ),
  );

  return $meta_boxes;
}
add_filter( 'rwmb_meta_boxes', 'arrivo_metabox' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.