WP_Object_Cache::switch_to_blog() WordPress Method
The WP_Object_Cache::switch_to_blog() function is used to switch the current WordPress site to a different blog. This function is useful for plugin and theme developers who need to access data from multiple WordPress sites.
WP_Object_Cache::switch_to_blog( int $blog_id ) #
Switches the internal blog ID.
Description
This changes the blog ID used to create keys in blog specific groups.
Parameters
- $blog_id
(int)(Required)Blog ID.
Source
File: wp-includes/class-wp-object-cache.php
public function switch_to_blog( $blog_id ) { $blog_id = (int) $blog_id; $this->blog_prefix = $this->multisite ? $blog_id . ':' : ''; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
3.5.0 | Introduced. |