Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [switch-to-blog]

The tag has no usage guidance.

0
votes
0answers
54 views

How do I use a combination of switch_to_blog() and wc_create_order()?

I'm looking for a way to create a WC order programmatically for a subsite in my multisite environment. When I use the following, the order is created on the main site and not the subsite with ID 7: ...
1
vote
1answer
18 views

restore_current_blog required after switch_to_blog, if I use that in a function?

class Basics { public function build_frontend_post_form( $blog_object ) { switch_to_blog( $blog_object->blog_id ); if( !( current_user_can( 'administrator' ) and ...
1
vote
1answer
24 views

Include Site 1 Posts in Query for Sub Sites

So I have a Primary site that posts announcements about the sub sites, for each of those posts I have a meta value that the user sets for which site those announcements apply too. On each of those sub ...
1
vote
0answers
44 views

What is the way to share data between sites in a multisite

We want to display the same data on multiple sites in a multisite. This data needs to be added/edited by the client. We can create a custom post type and use the switch_to_blog function to get the ...
1
vote
0answers
29 views

get post id by $content (so by post content)

So weird, huh? But, not joke --> I try to be very clean of being: I have a subdomain based multisite network. If the users posts to their sites, I get a clone from the current post to my network home. ...
1
vote
0answers
268 views

Using wp_enqueue_media() with switch_to_blog() issue

I'm using WordPress media upload through wp_enqueue_media(); to upload media. It works perfect. But, I'm using multisite. Media upload is available on all sub domains. If someone upload image from ...
0
votes
2answers
77 views

Get variable from previous blog while using switch_to_blog

I'm writing a query that switches to the main blog of a MU site using switch_to_blog(). All is well except i'm attempting to write a wp_query that includes a variable needed from the previous blog. ...
0
votes
0answers
353 views

switch_to_blog($blog_id); still writing to main blog

I'm creating new blogs (wpmu_create_blog) in a for loop, What I am trying to achieve now is to insert posts into each newly created blog using switch_to_blog. The problem is wp_insert_post still ...
0
votes
0answers
559 views

fatal Error undefined function switch_to_blog()

Hello All! I got this puzzling beginner issue. It's my first Multisite install, latest versions of all, no plugins, and when I am trying to use in a page template the switch_to_blog function, I get ...
1
vote
0answers
391 views

Register submenu on network menu from the subsite

I have a multisite like this: MainSite Site1 Site2 I want to register submenu page on active site in parent page /wp-admin/options-general.php on network in parent page /network/settings.php If ...
1
vote
0answers
105 views

Make a list of sites for each user in WPMU - switch_to_blog (display in SITE_ID: 1)

page.php (site_id= 1) <?php // view all sites for all users in site network ID 1 $blogs = get_blog_list( '0', 'all' ); // ALL BLOGS if ( 0 < count( $blogs ) ) : foreach( ...
0
votes
2answers
220 views

How to get all pages on specific blog after switch_to_blog?

I am attempting to loop through all sites on my multisite network blog. However, when I attempt to use get_pages it ignores the fact that the blog has switched via switch_to_blog. $sites = ...
-1
votes
1answer
65 views

Best Way to Inventory the Media Library of a 200+ Multisite Installation?

I have a multisite installation of WordPress with 200+ sites. I recently was tasked to do an inventory of each site's media library and was wondering if this could be accomplished programmatically ...
0
votes
1answer
335 views

Get_posts not returning any posts when used with switch_to_blog

I'm attempting to pull in some order information from the "shop_order" post_type. This is on a multisite network, so I'm using switch_to_blog(1). When I set the post type as "post" it works great and ...
0
votes
1answer
429 views

switch_to_blog() and wp_nav_menu() not functioning properly

I have an MU plugin active on the network with this small function to query menu 4 from the main site in my network. On the main site in the network (1) things work as expected. On the sub sites in ...
0
votes
1answer
1k views

get_term_by works but get_terms doesn't?

I currently have a Multisite with 2 sites. From the secondary site get_term_by() works to retrieve terms from the primary site, but get_terms() does not. I'm using switch_to_blog(1); but I get ...
0
votes
1answer
167 views

Do “switch_to_blog()” and “restore_current_blog()” re-run the filters?

I've been working on a Wordrepss multisite network and came across very common requirement of displaying a common navigation menu across all sites. Use switch_to_blog() and restore_current_blog()...
0
votes
2answers
223 views

Sort posts according to date

I have problem with sort posts according to date: My code now: <?php global $switched; $original_blog_id = get_current_blog_id(); // get current blog $blog_ids = array(4,1); foreach( $blog_ids ...
0
votes
1answer
297 views

Multisite switch to blog

I apologies before I start this question is vagus and I don't have any code to show as I'm working locally. I have a Wordpress Multisite, with 3 sites - 'site-1', 'site-2', 'site-3'. They all import ...
5
votes
1answer
269 views

switch_to_blog(): Load textdomain

I am using the WordPress multisite feature with Multilingual Press Pro to create a multilingual site with linked posts. In a network activated plugin the custom post types are registered. For ...
1
vote
0answers
2k views

Multisite wp_query & switch_to_blog issue

3/17/2015 update So it appears that this is a known issue with ACF and multisite using switch_to_blog. http://support.advancedcustomfields.com/forums/topic/multisite-switch_to_blog-options-issue/ ...
0
votes
1answer
896 views

How to update global header and footer

I have a problem with the global header and footer in multisite. When I change the root's header and footer, the subsites (all other blogs) don't update. This is my code: global $switched; ...
1
vote
2answers
814 views

the_post() within switch_to_blog() altering my excerpt

I have a strange problem I'm facing when using WP_Query with multisite in a plugin I'm writing which hooks into add_meta_boxes. I'm wanting to display all post titles in a dropdown in a meta box. ...
3
votes
1answer
399 views

Switch_to_blog() outside wordpress

how can I load switch_to_blog() function outside wordpress? $blog_id = '7'; require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' ); switch_to_blog($blog_id); echo get_option('blogname'); ...
0
votes
1answer
851 views

Strange switch_to_blog() issue

OK, so WordPress has been destroying me this afternoon and this particular issue I really can't figure out. We are building a multisite network and for our particular purpose need to loop through each ...
18
votes
1answer
900 views

How can I trust switch_to_blog()?

When I call switch_to_blog() with a blog id, I don’t know whether that blog actually exists. The function returns always TRUE. Test case: switch_to_blog( PHP_INT_MAX ); $post = get_post( 1 ); ...
0
votes
1answer
90 views

Access from template info of another blog (in the same network)

In my root blog (1), i have a custom post type that can be linked to an existing blog of my network. It does so by recording in post metas the ID of the blog it is linked to. I use _blog_id as a name ...
5
votes
3answers
2k views

Get Recent Posts by Date in Multisite

Everything in explanation is about CDTuts I've created a WordPress Network and I want is to get the recent posts from all of the selected subdomain blogs. I need to get the latest All organized by ...
0
votes
2answers
2k views

Get the excerpt by page ID from another blog in a wordpress multisite?

I am trying to get the first paragraph on a page where page ID=2 and blog ID=1. I want to display this paragraph on a page in blog id=2. I have added the following code to the template page. //gets ...
0
votes
1answer
53 views

Best Practise: Linking to WPMU sites from other sites

I'm digging through WPSE, and WP Codex/Core, and I am looking for essentially wpmu_blog_link( $blog_id ), which would essentially be home_url() with a parameter to pass the blog_id. I could easily ...
4
votes
1answer
1k views

switch_to_blog() performance considerations & alternatives

I'm currently in the conceptual phase for a multisite network. The rough idea is: There are multiple networked sites and all publish posts for their own. The network admin is able to establish "...
1
vote
1answer
1k views

Upload images from one site to another in Multisite

My multisite setup has one sort-of-admin site, where users can insert/edit posts and specify on which site they want 'em published. This is a contract requirement and cannot be changed. EDIT: Check ...
4
votes
1answer
4k views

Merging multiple wp_query objects

I have the code below for a multisite install. It works fine, but I need to merge each WP_Query loop object from each multisite together for use in another template with the WordPress loop. Is this ...
0
votes
2answers
295 views

switch_to_blog() for parent theme

all. Just trying out switch_to_blog() as a way to have a child site get some news items from the parent site. Problem is, the parent site--first tables in database--doesn't have a number, i.e., ...
3
votes
2answers
3k views

latest 5 posts using switch_to_blog loop

im sure i must be doing something wrong and would really appreciate a little help. I am trying to loop through all of my Sub Dir "Multisite" blogs using switch_to_blog, below: global $wpdb, $blog_id,...
8
votes
5answers
4k views

Sharing Dynamic Sidebars across Multisite Blogs

I'm trying to find away to retrive a dynamic sidebar from one blog and print it on another blog in the same install of Wordpress Multisite. I have tried switch_to_blog($blog_id); dynamic_sidebar($...
2
votes
1answer
2k views

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?

I am using a new blog on WPMS (3.0.1, updating is not an option) to aggregate posts (and their featured image) from a few blogs on the same install, and I have to do it programmatically rather than ...
0
votes
1answer
946 views

Is it a bad practice to use switch_to_blog in the frontend?

From Wordpress Codex (although related to the same function in WPMU and not WP3.0+): http://codex.wordpress.org/WPMU_Functions/switch_to_blog it says: This switch is to be used for internal and ...
0
votes
1answer
439 views

Bug using wp_insert_term with switch_to_blog

I'm running a network of about 80 sites using WP multisite 3.2. I'm experiencing irregularities using switch_to_blog whith wp_insert_term. To test this I have disabled all plugins, and am testing on ...
0
votes
1answer
178 views

Trouble with SQL SELECT inside switch_to_blog()

I'm using switch_to_blog() and restore_current_blog() to perform some functions across a multi site install. One of the things I'm trying to do is select a very specific post using get_row(). My ...