0

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 1

1

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.

1
  • Welcome! You can accept the answer if that worked for you (little checkbox under the score).
    – Pim
    Commented Oct 2, 2018 at 12:15

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.