Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is it possible for two separate blogs running on the same multisite installation to share tables in the database?

By default, Wordpress adds the blog ID to the table prefix for all of the associated tables such that blog #1's posts are stored in the wp_1_posts table, blog #2's posts in the wp_2_posts table etc..

However, for my peculiar development workflow I would like to use blog #1 for public use and blog #2 for development while sharing database tables between them such that any changes made to either blog are reflected on both immediately (i.e. both blog #1 and blog #2's posts are stored in wp_1_posts, their users in wp_1_users, and so forth).

Any ideas?

share|improve this question
2  
But this way when you make changes to your development site you will also change the public site –  Bainternet Jul 24 '11 at 16:29
2  
I'm quite sure I've seen a plugin that cross-posts in MS environment, but can't find it right now... And I think it's really not advisable to go the "shared tables" way... –  brasofilo Apr 8 '12 at 20:26

1 Answer 1

up vote 0 down vote accepted

You can switch back and forth between blogs on a multisite with switch_to_blog and restore_current_blog.

That should allow you to get anything you'd like and make queries as if you were actually on the other blog.

Check them out: http://codex.wordpress.org/WPMU_Functions/switch_to_blog http://codex.wordpress.org/WPMU_Functions/restore_current_blog

We did a lot of this with one of our recent sites.

share|improve this answer
    
...sorry this took 2 years to answer. –  MikeNGarrett Jan 19 at 4:39
    
I created my own solution at the time, but this one could be useful. Since no one else has answered, ill give the check to you. –  cnotethegr8 Jan 19 at 6:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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