0

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 admin area functions. It's too expensive a query to run on the front end.

in the new page for the same function in WP3+ there's no such mention.

So, is it a normal or a bad practice to use switch_to_blog in themes?

I have a multisite setup with 4 blogs and would like to use this function often to pull content from one to another.

2

For 4 blogs - most likely no.

The problems start to appear when you have tens of thousands of posts+ across many blogs, and you want to do queries like getting the latest 10 posts from the network.

You should test this yourself, and see if the use of that function (and the others that followed it) significantly affected site performance in some way

  • it's for a website I'm preparing therefore I don't know yet. But yeah there might be some day tens of thousands of posts. Especially because one of the 4 sites hosts a bbpress2 forum (that forum could easily get to that point). So, how should I solve this? There a few reasons why I need 4 sites. I have a main website, plus another website for administrators only, they should pull certain content from the main website to manage things. The third website is a small site with pages in two languages. And the fourth is the bbpress site also bilingual. The main website would pull latest forum posts. – unfulvio Dec 10 '11 at 13:50
  • Then it's ok. It all comes down to the type of query you want to make. As long as you're pulling out content only from one blog there won't be any significant speed impact. – onetrickpony Dec 10 '11 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.