Updating just one option with update_option


There are many options within an ‘option’ in the ‘wp_options’ table. This option, second_option, contains three parameters and consequently has three values. The values are, for example, as follows:

{s:12:"manual";s:0:""; s:8:"currency";s:3:"USD";s:14:"state";s:2:"nn";}

I want to update the value of the second parameter, and that is 'currency', yet whenever I want to update just this portion, WordPress just updates whole of the option and the first option and the third, that is 'manual' and 'state' are deleted and just remains what I am updating, that is 'currency'. I use the following piece of code:

$sets = get_option( 'second_option' );
$sets['currency'] = 'some_value';
update_option('second_option', $sets);

Is there a way to update just the option 'currency' without affecting other parameters, that is 'manual' and 'state'?

Thanks in advance.

H. M.. 2 years 2020-12-19T08:10:20-05:00 0 Answers 7 views 0

Leave an answer