Support

Account

Home Forums Backend Issues (wp-admin) Set image as featured image Reply To: Set image as featured image

  • Hello,

    I was searching for how to add a feature image through ACF Form, but I ended up here, and this helped me to find the solution.

    I hope this helps you.

    
    add_action('acf/save_post', 'acf_set_featured_image');
    
    function acf_set_featured_image($post_id){
        $value = get_field('post_image', $post_id);
    
        if($value != ''){
    	    add_post_meta($post_id, '_thumbnail_id', $value);
        }
    
        return $value;
    }
    

    This action check if you updated the field “post_image” from a frontend form and update the feature image with the same image.