Title: wp_cache_switch_to_blog
Published: April 25, 2014
Last modified: April 28, 2025

---

# wp_cache_switch_to_blog( int $blog_id )

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_cache_switch_to_blog/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/wp_cache_switch_to_blog/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_cache_switch_to_blog/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/wp_cache_switch_to_blog/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_cache_switch_to_blog/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_cache_switch_to_blog/?output_format=md#changelog)

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

Switches the internal blog ID.

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

This changes the blog id used to create keys in blog specific groups.

### 󠀁[See also](https://developer.wordpress.org/reference/functions/wp_cache_switch_to_blog/?output_format=md#see-also)󠁿

 * [WP_Object_Cache::switch_to_blog()](https://developer.wordpress.org/reference/classes/WP_Object_Cache/switch_to_blog/)

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

 `$blog_id`intrequired

Site ID.

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

    ```php
    function wp_cache_switch_to_blog( $blog_id ) {
    	global $wp_object_cache;

    	$wp_object_cache->switch_to_blog( $blog_id );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/cache.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/cache.php#L385)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/cache.php#L385-L389)

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

| Uses | Description | 
| [WP_Object_Cache::switch_to_blog()](https://developer.wordpress.org/reference/classes/wp_object_cache/switch_to_blog/)`wp-includes/class-wp-object-cache.php` |

Switches the internal blog ID.

  |

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

Starts the WordPress object cache.

  | 
| [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/) .

  |

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

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

## User Contributed Notes

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