Your code, which I assume is in a function, should pass variables needed from the current blog. So, assuming that your code in your question is called by somefunction(), change that to pass along variables from the current blog, as in
// variables from the current blog
$current_blog_1 = "some value"
$current_blog_2 = "another value"
// do the code in the original question
somefunction ($current_blog_1, $current_blog_2);
It might even be more efficient to put current_blog values in an array, as in
// set some values before you call your code via a function
$current_blog_array = array();
$current_blog_array[] = "some value";
$current_blog_array[] = "another value";
// call the function with an array, empty if needed
somefunction ($current_blog_array = array());
Then process the array values in your original code.
Related Posts:
- How can I trust switch_to_blog()?
- Sharing Dynamic Sidebars across Multisite Blogs
- latest 5 posts using switch_to_blog loop
- using 1 form shortcode (si or cf7) for all multisite sites [closed]
- Multisite Installation: how do I setup global search?
- Switch_to_blog() outside wordpress
- why when I try to insert an image attachment along with a post does wp_get_attachment_url give me a very wrong file path?
- Upload images from one site to another in Multisite
- What is the way to share data between sites in a multisite
- get post id by $content (so by post content)
- Register submenu on network menu from the subsite
- Include Site 1 Posts in Query for Sub Sites
- Sort posts according to date
- Multisite switch to blog
- Best Practise: Linking to WPMU sites from other sites
- Is a multisite install what I need?
- Trouble with SQL SELECT inside switch_to_blog()
- Display posts from one network site on another
- switch_to_blog($blog_id); still writing to main blog
- fatal Error undefined function switch_to_blog()
- How to get all pages on specific blog after switch_to_blog?
- Do “switch_to_blog()” and “restore_current_blog()” re-run the filters?
- Access from template info of another blog (in the same network)
- Get the excerpt by page ID from another blog in a wordpress multisite?
- Memory growth with new additions to WordPress Multisite
- How to add Custom Blog Options to new blog setup form?
- Remove the blog slug from WordPress Multisite root node
- How to run an activation function when plugin is network activated on multisite?
- Specific upload folder for PDFs in custom Post type in WP multisite
- How can I un-reserve a pending username registration?
- Redirect Main Site to Subsite in Multisite WordPress
- WordPress Multisite: Adding actions to only one site
- wordpress multisite, how to keep user on subdomain throughout registration process?
- Can I set some default pages to be created on every creation of a new blog
- Is there any central control/access panel for several WordPress sites?
- Get Recent Posts by Date in Multisite
- Changing subdir multisite install to subdir core directory structure
- get_current_blog_id returns 1 in multisite setting
- On WP Multi sites how many sites…!
- How do I share plugin settings across WordPress network?
- How would I use pre_get_posts to query another site for posts in my multisite network?
- How to set up WordPress Multisite on multiple domains without plugin?
- Blog Settings import/export in WordPress Network environment
- Odd Script File Trying to be Loaded
- share login/logout sessions across two installs?
- Multiple domain names under one WordPress Installation
- What is the most comprehensive backup plugin for WordPress (it does not have to be free)? [closed]
- Multisite wordpress and subdomain URL collisions
- WordPress Multisite: Automatically run importer upon creating new site
- Basically the opposite MultiSite URL question that most people ask
- Multisite wp-admin redirect loop
- setup Multi Multi-site with one installation?
- Auto create pages on WordPress multi site register
- Multiple sites (separate domains) running from one WordPress site
- Add Rewrite Rule to point to a file on the server
- How do I use different domain for subdomains in WP Multisite?
- Multisite WordPress nginx uploaded files throw 404
- subdomain mulitsite on localhost in a subfolder
- Exclude main blog from get_blogs_of_user
- WordPress Network for regional company websites
- How to do Domain Mapping to Subdirectories?
- Limit multisite/network site names to a property of the user
- How to set Active plugins as the default screen?
- Why can’t I delete original user in multisite? Options for manual removal
- Global searchin multisite but only with one subsite
- Subdirectory multisite installation with several domain names?
- Can’t access WordPress multisite after connecting to domain
- In MultiSite, can some users automatically have Site Admin rights on all sites, without granting them Network Admin access?
- Media library not loading after switching the main site of multisite
- Multisite media library uploads broken images
- create_users capabilities on a role on multisite
- Any downsides on using Multisite for many look-alike-websites?
- WordPress Images Not Showing When FTP
- Multisite Super admin and Network admin emails
- Is there a way to run upgrade.php for one blog?
- How to run a subdirectory multisite install under a subdomain
- How do I list multisite users for the current site only
- Using Two Themes – One for Main Site, One for Ecommerce
- WordPress Multisite – configuring a local development copy
- Domain name in a WordPress Network
- How to change user starting role in WordPress MultiSite?
- get_post_type_object() does not work with switch_to_blog()
- Multilanguage site with two domains
- Site not found using subdomains
- Is it possible to install BuddyPress with blogs installed on several servers? [closed]
- All wordpress network subfolder sites being redirected to main site
- Get current Blog ID in Tinymce Plugin Dialog Window in WPMU
- Grandchild themes and optimal network architecture
- Multi-Site Subdomain: Show master site under subdomain if no sub site exists
- Multisite – Change Add user to Blog notification email
- Register existing user on another site in a multisite network?
- URL without www redirect directly with submission page – Multiwordpress install
- Can i import a site (plugins, database, images) etc. Into an existing wordpress multisite?
- WordPress Multisite + Erros with URLS and ADMIN
- Create Custom Multisite User Role to Reduce Capabilities
- Importing XML didn’t finish, site is now inaccessible
- WordPress multisite – Bitnami
- How can I tell if a wordpress site is running on multisite?
- Adding hreflang to multisite with no plugin?
- Obtaining user table for one site on multisite set up