Skip to content

Instantly share code, notes, and snippets.

@kevinwhoffman
Created January 30, 2016 16:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinwhoffman/0f6b6530564f4aef61fe to your computer and use it in GitHub Desktop.
Save kevinwhoffman/0f6b6530564f4aef61fe to your computer and use it in GitHub Desktop.
Update post thumbnail with value of ACF Image field
<?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