I'm using the IMDB Connecter plugin to grab meta data for movies and I'm wondering if I can save some of the information it generates as custom meta data.

Basically, I want to be able to save the "Language" and "Actors" information generated by the plugin in meta fields with the same name so that posts are searchable using these values.

This is how I currently output the data in my single.php file;

$imdb = get_field('imdb_id'); // IMDB movie ID is saved as a custom meta value
$imdbInfo = get_imdb_connector_movie($imdb);
$actors = $imdbInfo['actors']; // Gets an array of actor names
$language = $imdbInfo['languages']; // Gets an array of languages

Is it possible to save these values as custom meta?

Any nudge in the right direction would be most appreciated


1 Answer 1


Use the wp_insert_post hook to run when a post is saved:

function wpse_188435_save_movie_data( $post_id ) {
    if ( $imdb = get_field( 'imdb_id', $post_id ) ) {
        if ( $imdbInfo = get_imdb_connector_movie( $imdb ) ) {
            if ( isset( $imdbInfo['actors'] ) )
                update_post_meta( $post_id, 'actors', $imdbInfo['actors'] );
            if ( isset( $imdbInfo['languages'] ) )
                update_post_meta( $post_id, 'languages', $imdbInfo['languages'] );

add_action( 'wp_insert_post', 'wpse_188435_save_movie_data', 50 /* Late priority, will ensure ACF has saved all data first */ );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.