Linked Questions

-1 votes
1 answer
580 views

restore_current_blog() vs. multiple switch_to_blog() followed by removing $GLOBALS['_wp_switched_stack'] [duplicate]

Related to this answer, which states 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 ...
Pat J's user avatar
  • 11.8k
20 votes
2 answers
38k views

Get posts from sites in Multisite?

I'm trying to pull multiple sites posts. For example, I can pull out a single site posts by a category and total posts 10. But I'm trying to pull out both posts from two separate Multisite blogs 1 &...
DeadArtcore's user avatar
0 votes
2 answers
6k views

List all sites in multisite

I want to list all sites in the multi site network in alphabetical order? Right now, the code lists by registered date <?php // Query for getting blogs $blogs = $wpdb->get_results( $...
Ruriko's user avatar
  • 543
4 votes
2 answers
3k views

How would I use pre_get_posts to query another site for posts in my multisite network?

I have a multisite network of sites which should display blog content from each other if the blog post has a tag with the site name. To gather all posts within the network I use the SWT (Sitewide ...
Johan Nordström's user avatar
1 vote
2 answers
1k views

Loop (iterate) through Multi-Site sub-sites (blogs)?

What is the easiest approach to iterate through the sub-sites (in Multi-Site network) and let's say add_option("xyz", 123) for each of site.
T.Todua's user avatar
  • 5,789
0 votes
2 answers
2k 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 ...
cfnne's user avatar
  • 1
3 votes
1 answer
1k views

Hierarchical Page Listing of all Pages in a Multisite Network

I would like to create a page template that does a listing of all pages across all blogs within a multisite network and list those pages starting with the blog name of the site and then list out the ...
Alex V.'s user avatar
  • 158
0 votes
1 answer
502 views

Count posts on multisite with blog id

How would I use a blog/site id to count posts from the id specified site much like wp_count_posts() does for the current site? I'm trying to create a function for an AJAX accessed endpoint where a ...
ExcellentSP's user avatar
0 votes
0 answers
481 views

In a WordPress multisite configuration, how do I instruct WP_Query() to return posts from a sub-site?

I have a WordPress multisite with one main site and four sub-sites. All five sites have a custom post type with the name property, and each site has several posts of this type. In a PHP template on ...
cag8f's user avatar
  • 1,907
2 votes
1 answer
357 views

Delete pages and Create default pages for all new network sites

I am using the following code to delete some default pages and to also create some default pages for all new sites that are created. It work as is now but that is only because I purposely have a ...
730wavy's user avatar
  • 193
0 votes
1 answer
124 views

Woocommerce Multisite Search Mod to archive.php but no pagination

Im modifyng archive.php in my woocommerce theme to have multisite global search. I added this code: if ( is_search() ) { $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $...
Vito Santimone's user avatar