Codex

Function Reference/switch to blog

Contents

Description

Switch the current blog to a different blog. switch_to_blog(), is useful if you need to pull posts or other information from other blogs.

You can switch back afterwards using restore_current_blog().

Things that aren't switched:

Parameters

$new_blog
(integer) (required) The id of the blog you want to switch to. Default: current blog
Default: None
$validate
(boolean) (optional) Whether to check if $new_blog exists before proceeding
Default: false

Return Values

(bool) 
true on success, false if the validation failed

false if $validate=true is passed and no such blog exists; otherwise true (even when "switching" to the current blog).

Source File

switch_to_blog() is located in wp-includes/ms-blogs.php

You can switch back afterwards using restore_current_blog()