I want to update an option, but instead of replacing the old value with the new one, Ì want to add new value to existing one. So the new value should be $oldvalue + $newvalue. I read about pre_update_option filter, but haven't understand how to do what I need.
1 Answer
Use update_option()
in conjunction with get_option()
:
$old_option = get_option('blogdescription');
$new_option = 'My new blog description';
$new_option .= $old_option; // This is the same as $new_option = $new_option . $old_option;
update_option('blogdescription', $new_option);
If they are integers, obviously use something like $new_option += $old_option
.
-
Welcome! You can accept the answer if that worked for you (little checkbox under the score).– PimCommented Oct 2, 2018 at 12:15