Leave a Reply

1 comment

  1. <?php
    // Check to make sure array is ready
    if( isset($_POST['activite_dates']) && is_array($_POST['activite_dates']) ) {
        // If we have an array ready to save delete all the previous data
        delete_post_meta( $post_id, "dates");
        foreach($_POST['activite_dates'] as $date) {
            // Use add post meta instead of passing the array directly in
            add_post_meta( $post_id, "dates", esc_attr($date));
        }
    }
    
    
    
    $dates_gf = get_post_meta( $object->ID, 'dates', false );
    
    // No need for the is_array() check when using false for the $single variable. Check for empty() instead
    if(!empty($dates_gf)) {
        foreach($dates_gf as $date_gf) {
            ?> <input type="text" name="activite_dates_gf[]" value="<?php echo $date_gf; ?>" size="30" /><br /> <?php
        }
    } ?>