Support

Account

Home Forums Backend Issues (wp-admin) Get featured image and save as field Reply To: Get featured image and save as field

  • 
    add_action('acf/save_post', 'move_image_to_post_thumbnail');
    function move_image_to_post_thumbnail($post_id) {
      if (get_field('your-image-field-name', $post_id, false)) {
        // get unformatted value
        // we did it above too, no point formatting the value for this
        $image_id = get_field('your-image-field-name', $post_id, false);
        update_post_meta($post_id, '_thumbnail_id', $image_id);
      }
    }