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.


Top ↑

Parameters

$blog_id

(int)(Required)Blog ID.


Top ↑

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 . ':' : '';
	}


Top ↑

Changelog

Changelog
VersionDescription
3.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.