switch_to_blog

SummerySummery

Switch the current blog.

Syntax

switch_to_blog( int $new_blog_id, bool $deprecated = null )

DescriptionDescription

This function 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:

  • plugins. See #14941

ParametersParameters

$new_blog_id

(int) (Required) The ID of the blog to switch to. Default: current blog.

$deprecated

(bool) (Optional) Not used.

Default value: null

ReturnReturn

(true) Always returns true.

SourceSource

File: wp-includes/ms-blogs.php


			

ChangelogChangelog

Changelog
Version Description
MU (3.0.0) Introduced.

See alsoSee also

Scroll to Top