restore_current_blog() vs switch_to_blog()
After every instance of switch_to_blog() you need to call restore_current_blog() otherwise WP will think it is in a “switched” mode and can potentially return incorrect data. If you view the source code for both functions you will see those functions push/pop data into a global called $GLOBALS[‘_wp_switched_stack’]. If you do not call restore_current_blog() after every … Read more