您可以使用save_post
钩子,这是一个钩子,一旦柱子被保存,它就会开火。下面是一个解决您想要实现的目标的示例:
function wpse253778_calculate_values( $post_id, $post ) {
if ( \'post\' !== $post->post_type )
return;
$field = get_post_meta( $post_id, \'FIELD_NAME\', true ); //get field value
$new_field_value = \'\';//calculate new field value
update_post_meta( $post_id, \'NEW_FIELD\', $new_field_value );
}
add_action( \'save_post\', \'wpse253778_calculate_values\', 10, 2 );