Title: add_blog_option
Published: April 25, 2014
Last modified: May 20, 2026

---

# add_blog_option( int $id, string $option, mixed $value ): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#wp--skip-link--target)

Adds a new option for a given blog ID.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#description)󠁿

You do not need to serialize values. If the value needs to be serialized, then it
will be serialized before it is inserted into the database. Remember, resources 
can not be serialized or added as an option.

You can create options without values and then update the values later.
Existing
options will not be updated and checks are performed to ensure that you aren’t adding
a protected WordPress option. Care should be taken to not name options the same 
as the ones which are protected.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#parameters)󠁿

 `$id`intrequired

A blog ID. Can be null to refer to the current blog.

`$option`stringrequired

Name of option to add. Expected to not be SQL-escaped.

`$value`mixedrequired

Option value, can be anything. Expected to not be SQL-escaped.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#return)󠁿

 bool True if the option was added, false otherwise.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#source)󠁿

    ```php
    function add_blog_option( $id, $option, $value ) {
    	$id = (int) $id;

    	if ( empty( $id ) ) {
    		$id = get_current_blog_id();
    	}

    	if ( get_current_blog_id() === $id ) {
    		return add_option( $option, $value );
    	}

    	switch_to_blog( $id );
    	$return = add_option( $option, $value );
    	restore_current_blog();

    	return $return;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/ms-blogs.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/ms-blogs.php#L404)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/ms-blogs.php#L404-L420)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#related)󠁿

| Uses | Description | 
| [add_option()](https://developer.wordpress.org/reference/functions/add_option/)`wp-includes/option.php` |

Adds a new option.

  | 
| [switch_to_blog()](https://developer.wordpress.org/reference/functions/switch_to_blog/)`wp-includes/ms-blogs.php` |

Switches the current blog.

  | 
| [restore_current_blog()](https://developer.wordpress.org/reference/functions/restore_current_blog/)`wp-includes/ms-blogs.php` |

Restores the current blog, after calling [switch_to_blog()](https://developer.wordpress.org/reference/functions/switch_to_blog/) .

  | 
| [get_current_blog_id()](https://developer.wordpress.org/reference/functions/get_current_blog_id/)`wp-includes/load.php` |

Retrieves the current site ID.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#changelog)󠁿

| Version | Description | 
| [MU (3.0.0)](https://developer.wordpress.org/reference/since/mu.3.0.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/add_blog_option/?output_format=md#comment-content-3901)
 2.   [MakeWebBetter](https://profiles.wordpress.org/makewebbetter/)  [  6 years ago  ](https://developer.wordpress.org/reference/functions/add_blog_option/#comment-3901)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_blog_option%2F%23comment-3901)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_blog_option%2F%23comment-3901)
 4. **Usage of [add_blog_option()](https://developer.wordpress.org/reference/functions/add_blog_option/)
    for multisite. **
 5.     ```php
        // passing $blogID for which option need to add
        function wpdocs_MWBOption( $name, $value, $blogID ) {
             if ( is_multisite() ) {
                 return add_blog_option( $blogID, $name, $value );
             }
             return add_option( $name, $value );
        }
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_blog_option%2F%3Freplytocom%3D3901%23feedback-editor-3901)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fadd_blog_option%2F)
before being able to contribute a note or feedback.