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?
- How do I remove/delete an old super admin user?
- Setting up a wordpress network with third level domains
- How will self-hosted WordPress work with Google Page Speed Service?
- Troubleshooting a “You do not have sufficient permissions to access this page” error
- What is the best way to load the WP environment in a subdomain of my multisite WordPress install?
- Benefits or Problems for using Sub-Directory vs Sub-Domain install of WP Network
- What methods should be used to fend off splogs in a multiuser install? [closed]
- WordPress 3 Multisite using subdomains.- DNS on Cpanel question
- Remove Site Name from register form – Multisite
- Set up collaborative site
- How to disable Multisite sign-up page?
- Add role across network in multisite
- How to Login Once to an Entire WP Multisite Network
- NGINX Multisite Rewrite rules
- On Multisite: Loop to Show First Four Images of Recent Posts Across Network
- “Preview Changes” button doesn’t show changes for previously published posts/pages
- Tax_query not working on multisite
- Can I manage more wordpress sites with one wordpress administrator page? [closed]
- Subsites in Multisite installation throwing 404 error on wp-admin in IIS 7
- Identical members roles on all sites in a multisite
- Fixing media links after importing to multisite
- How do I maintain static directories on multisite subdomains?
- WP-CLI can’t list posts
- Woocommerce and different checkout field for different countries
- Why is multisite rest API keep giving me results for root site only?
- How to stay logged in on a multisite with different domains?
- wordpress multisite subsite rewrite rules not working for videos
- What should I do? A multisite, a single website or many websites? [closed]
- Custom Post types and Custom fields in Multisite
- Can a user spread virus on my Multisite?
- Use another author.php if different multisite subsite?
- Subsite with different template, and content
- What is best forum script available to integrate with wordpress?
- Link to Network Admin Broken After Switching to HTTPS
- Making 2 WordPress sites mutually searchable and more
- Multi-site get_bloginfo(‘stylesheet_directory’) referring to sub-folder
- Unable to apply theme to WordPress Network Site install
- How to convert multi-site to single site
- Create a homepage like WordPress.com?
- Use WordPress MultiSite (WPMS) with a remote database for each created site
- Redirect old uploads after moving to multisite
- URL for images folder on Multisite
- Best architecture for multiple websites
- Admin permission for creating blogs in multisite
- Will WP work on a multi-server environment? [duplicate]
- Amazon EC2 and static page Caching (Multisite): How to enable Caching with multiple instances?
- How to check if page exists in Multisite?
- WordPress MU wp_posts table
- WordPress Multisite (sub-directory based), change subsite URL
- 403 forbidden when changing settings on WP Multisite non-main sites
- Migrating wordpress sites through localhost and ubuntu
- WordPress multisite with only two level of sub-domains?
- WordPress multisite with separate domains
- Multisite are not creating folders for the subsites
- Customize or avoid new admin email address notification
- After setting up multisite on localhost, requests to localhost redirect to production domain
- How to use same theme in different languages?
- Blog & Portfolio setup
- How can I restrict changing the max nested comment levels option to super admins?
- How can I create network with different domains?
- Problem moving wordpress multisite
- Can I run both a wordpress blog plus another service(ex. a Shopify store) on the same domain?
- WordPress Multsite Network site under another network site
- WordPress Upgrade – API files returning 404 on Multisite
- Activate User account for Sub Site broken
- new WPMS site not working / Q setting up new site/subdomain
- wordpress multisite config issue needs help
- Creating a stand-alone site from a WordPress sub site
- Multisite read_more link displays URL twice
- Multisite: Run a subdomain install from a directory install
- Plugin data shared in Multisite
- Remove blog slug from WPMU?
- WordPress multisite and one database
- Planning on Multisite Before Creating A Network
- Trying to create site-wide Active Directory sync with Multisite
- WPMU and Chrimes Family Link app