Home Forums Backend Issues (wp-admin) "Featured image" still intact upon removal Reply To: "Featured image" still intact upon removal

  • You need to update the post parent of the image to attach it to the post, you could to that in the same function that you’re using to set the featured image.

    function acf_set_featured_image($value, $post_id, $field ){
      if ($value != '') {
        //Add the value which is the image ID to the _thumbnail_id meta data for the current post
        add_post_meta($post_id, '_thumbnail_id', $value);
        // attach image to post
            'ID' => $value, 
            'post_parent' => $post_id
      } else {
        delete_post_meta($post_id,'_thumbnail_id', $value);
      return $value;
    // acf/update_value/name={$field_name} - filter for a specific field based on it's name
    add_filter('acf/update_value/name=cursusfoto', 'acf_set_featured_image', 10, 3);