最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

database - Share DB tables between two blogs on the same WP Multisite installation

programmeradmin0浏览0评论

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?

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 edited Apr 25, 2013 at 23:05 bosco 7,0343 gold badges28 silver badges47 bronze badges asked Jul 24, 2011 at 15:26 cnotethegr8cnotethegr8 3592 gold badges9 silver badges21 bronze badges 2
  • 2 But this way when you make changes to your development site you will also change the public site – Bainternet Commented Jul 24, 2011 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 Commented Apr 8, 2012 at 20:26
Add a comment  | 

1 Answer 1

Reset to default 0

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/WPMU_Functions/switch_to_blog http://codex.wordpress/WPMU_Functions/restore_current_blog

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

发布评论

评论列表(0)

  1. 暂无评论