I have a custom post type where the user can set a video 'url' custom field. I need to download meta-data about the video (e.g. title, description, thumbnail) and store it along with the rest of the post's data.

Since downloading this data can be a bit long, I'd like to do this only when it's necessary, i.e. when the 'url' field has changed.

Is there a way to check whether a field's value has changed on save_post ?

  • edit the question to add the code which save this metafield
    – mmm
    Commented Nov 3, 2017 at 11:07

1 Answer 1


Usually there is no way to check if the meta data is updated or not, but you can use updated_postmeta and added_post_meta to get kinda similar functionality. Please have a look at the below code-

add_action( 'updated_postmeta', 'the_dramatist_updated_postmeta', 10, 4 );
add_action( 'added_post_meta', 'the_dramatist_updated_postmeta', 10, 4 );
function the_dramatist_updated_postmeta(
) {
    // check meta key with $meta_key parameter
    if ( 'your_meta_key' !== $meta_key ) {
    // better check with the exiting data with the $meta_value to check if the data is updated or not.
    // then do what you want to do with the data

Hope this above helps.

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.