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

  • Hi @jonathan , I have read this topic and tried to adapt it to my needs but it is not working. Maybe you could help me our here. I have a CPT with some images. I would like to define of of the images as my featured image. The image is called “1_bild” and I have set it as an image-array at the ACF configuration. I have used the following code but it does not work for me:

    //Auto assign Featured image from 'post_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
    	    update_post_meta($post_id, '_thumbnail_id', $value->ID);
        return $value;
    add_filter('acf/update_value/key=1_bild', 'acf_set_featured_image', 10, 3);

    What am I doing wrong here?

    Thanks a lot!