Created
January 30, 2016 16:40
-
-
Save kevinwhoffman/0f6b6530564f4aef61fe to your computer and use it in GitHub Desktop.
Update post thumbnail with value of ACF Image field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function acf_update_post_thumbnail( $post_id ) { | |
$thumbnail_id = get_post_meta( $post_id, 'acf_image_field' ); | |
set_post_thumbnail( $post_id, $thumbnail_id ); | |
} | |
// run after ACF saves the $_POST['acf'] data | |
add_action( 'acf/save_post', 'acf_update_post_thumbnail', 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment