Use update_post_meta()
, because if the meta key already exists add_post_meta()
will do nothing if $unique
is true
and otherwise won't update eitherneither, while update_post_meta()
, well, it will update the value of a existing field or create it, if it doesn't exist yet.