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.
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.