Home › Forums › General Issues › Set featured image of CPT from existing image › Reply To: Set featured image of CPT from existing image
Yes, there is. You create an acf/save_post action http://www.advancedcustomfields.com/resources/acfsave_post/
In your function you get the value of the field which is stored as an ID. You can either do it with ACF using $image = get_field('image_field', $post_id, false);
which will return the ID value or you can use $image = get_post_meta($post_id, '', true);
then you do
$image = intval($image); // make sure it's an int
set_post_thumbnail($post_id, $image);
But this won’t be retroactive, you’d need to update every post.
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.