update_site_option()
updates an option that’s set for the entire network. If you’re trying to update a specific site’s option, eg blogname
, you’ll need to do update_option()
instead.
If you’re not sure of a site’s ID, you can get its details using the site’s slug with get_blog_details()
.
For example, if I wanted to change the admin_email
and some_other_option
options of the site at example.com/site-3:
$site_object = get_blog_details( 'site-3' );
if ( ! empty( $site_object ) ) {
switch_to_blog( $site_object->blog_id );
update_option( 'admin_email', '[email protected]' );
update_option( 'some_other_option', 'Some Other Option Value' );
restore_current_blog();
}
The confusion arises because when WordPress Multisite was initially developed, the terminology spoke of a site of blogs; later, though, it was updated to be a network of sites. The original terms still exist in function names like update_site_option()
and switch_to_blog()
.