WordPress Multisite allows us to have a network of blogs. Many times the sites from the network may be related, and also the information they contain.
What to do if you are developing a theme, or a plugin, for one of your sites and you want to query posts from another site?
You can use the function switch_to_blog() to change the database we are using. A way to do this would be:
- Save current blog_id
- Change blog_id with switch_to_blog function
- Do the query (query_posts, get_posts, etc)
- Restore original blog_id
Here is an example code snippet:
[Read more…] about WordPress Multisite: How to query posts from any site from the network