switch_to_blog() performance considerations & alternatives

You should first read (emphasis mine):

The sites in a multisite network are separate, very like the separate
blogs at WordPress.com. They are not interconnected like things in
other kinds of networks (even though plugins can create various kinds
of interconnections between the sites). If you plan on creating sites
that are strongly interconnected, that share data, or share users,
then a multisite network might not be the best solution
.

http://codex.wordpress.org/Before_You_Create_A_Network

If you insist on making multisite do what it is not intended to do, and instead do what it seems that most people want it to do, then you have a lot of work to do. You should be able to get WP_Query to honor your site switches via its numerous filters, especially these. And some function run their own queries, so you will have to deal with those individually.

It sounds like multisite is the wrong way to approach this. When I need something like this I tend to do it with custom post types. You’d create one CPT for each “blog”, though I have to admit that I’ve never tried to create 100 CPTs on the same site. The raw post total (20,000) shouldn’t be a problem though. With clever use of templates you can “virtualize” those into a visually nearly independent sites.

Given your comment below that you need “domain mapping, seperated userbases and seperate admin areas”, I am not sure that will work. You could probably get the domain mapping to work, but the separate userbases and admin areas would be a lot of work. That is one of the only other options I can think of though.

Leave a Comment