WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanted to update custom blog option created thru Settings Api using the function update_blog_option. I created this code.

    $country_base = get_blog_option($blog_id, 'mytheme_options');//retrieve all options
    $country_base['country_base'] = $the_country;
    $currency_unit = get_blog_option($blog_id, 'mytheme_options');//retrieve all options
    $currency_unit['currency_unit'] = $d_currency;

    update_blog_option($blog_id, 'mytheme_options', $country_base);
    update_blog_option($blog_id, 'mytheme_options', $currency_unit);

However, its not working.. Is there way to update custom blog option?

share|improve this question
up vote 1 down vote accepted

As per the Codex on update_blog_option:

Switches to the blog id specified, runs update_option() and then restores to the current blog. If $refresh is true then it will refresh the blog details.

Not tested, but I think your problem is trying to update elements of the array instead of the whole thing:

$the_options = get_blog_option($blog_id, 'mytheme_options');//retrieve all options

$the_options['country_base'] = $the_country;
$the_options['currency_unit'] = $d_currency;

update_blog_option($blog_id, 'mytheme_options', $the_options);
share|improve this answer

I think it's best just to switch_to_blog($id); and use regular functions as add_option(), get_option(), update_option(). When you're done you'd better use restore_current_blog(); to switch back.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.