switch_to_blog
switch_to_blog ( $new_blog_id, $deprecated = null )
Parameters:- (int) new_blog_id The ID of the blog to switch to. Default: current blog.
- (bool) deprecated Not used.
See:Returns:- (true) Always returns true.
Defined at:Change Log: - Introduced in WordPress: —
- Deprecated in WordPress: —
Description
Switches the current blog.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().
PHP code loaded with the originally requested site, such as code from a plugin or theme, does not switch. See #14941.