Support

Account

Home Forums Backend Issues (wp-admin) Using Date & Time Picker To Set Post Date for Custom Post Type

Helping

Using Date & Time Picker To Set Post Date for Custom Post Type

  • I am trying to get ACF to set the Publish Date for a custom post type that runs a simple event calendar. I found this code but I am not sure if it works for custom post types or for every post type:

    // Save ACF custom field to date-time post
    function my_acf_save_post( $post_id ) {
        $acfDate = get_field('initial_time_var', $post_id);
        //Test if you receive the data field correctly:
        //echo $acfDate;
        //exit (-1);
        $my_post = array();
        $my_post['ID'] = $post_id;
        $my_post['post_date'] = $acfDate;
        wp_update_post( $my_post );
    }
    add_action('acf/save_post', 'my_acf_save_post', 20);

    any guidance would be greatly appreciated.

  • This worked like a charm. Feel free to delete this thread if you want.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Using Date & Time Picker To Set Post Date for Custom Post Type’ is closed to new replies.