通常无法检查元数据是否更新,但您可以使用updated_postmeta
和added_post_meta
获得类似的功能。请查看以下代码-
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(
$meta_id,
$object_id,
$meta_key,
$meta_value
) {
// check meta key with $meta_key parameter
if ( \'your_meta_key\' !== $meta_key ) {
return;
}
// 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
}
希望以上内容有所帮助。