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!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.