WordPress.org

Codex

WPMU Functions/restore current blog

Contents

Description

Restores previous blog after a switch_to_blog call.

Contrary to the function's name, this does NOT restore the original blog but the previous blog. Calling `switch_to_blog()` twice in a row and then calling this function will result in being on the blog set by the first `switch_to_blog()` call.

Parameters

None

Return Values

(boolean) 
True if blog was restored, false if If you had never called switch_to_blog.
(global) 
Sets up a global variable called: switched.

Usage

<?php restore_current_blog(); ?>

Examples

<?php
    
global $switched;
    
switch_to_blog(7);
    echo 
'You switched from blog ' $switched ' to 7';
    
restore_current_blog();
    echo 
'You switched back.';
?>

Related Functions

Restore current blog should only be called after switch_to_blog.