One install to rule them all
by Martin on 8/05/2008Edit: This post was imported from my previous site and is completely outdated. FYI.
So, as I wouldn’t shut up about in this post I’m doing this little experiment with three blogs where one should suffice. Don’t ask why. It’s an Idea I got and I refuse to let it go. After trying a lot of different methods, all of them painful, I finally managed to accumulate the wisdom of the internets to achieve my perhaps ill-concieved goal. In case you wish to travel the same perilous path; here for your benefit is a summary.
I’d like to disclose right away that almost everything in this post is lifted from this post and the comments therein. I only parrot it here with some supplementary info for the exact situation I was in.
Anyway, what I wanted was this;
I have three blogs on three separate domains. On one blog I post about tech, code, web development and so forth. On another blog I post about mental health, bipolar disorder and all that fun stuff. I’ve decided to keep these separate because not everyone interested in one of the subjects would be interested in the other. So I needed a third blog for those that actually did want both, oh and then there were some posts that really should go on all three blogs, and… Complete and utter mess. I needed some way of posting a post once, and decide what blogs it should be visible on.
Confused? Here’s a diagram.

Right. So to achieve this we need to do some hackery. To be more exact we need to have three installations of WordPress share a single set of database tables. I might as well say right away that if the word MySQL means nothing to you, this isn’t for you. Also these because these installations need to share the same database, there’s a more than decent guess to say that your domains should share a single host. Nuff warnings. Let’s roll.
Step one: Install your different WordPress blogs. Give them all unique table prefixes (you’ll have to, or the installation won’t finish). Write these prefixes down. In this example my “main” blog will have the table prefix “main_wp_” and my “slave” blog will have the prefix “slave_wp_” You now have two or more separate blogs, presumably on two or more separate domains. Create your admin account on each of them.

Step two: FTP to your WP-folder on the slave blog, and find the file
1 | wp-includes/wp-db-php |
.
Open it up in a text editor and find the line:
1 2 | foreach ( $this->tables as $table ) $this->$table = $this->prefix . $table; |
Directly below it insert:
1 2 3 4 5 6 7 8 9 10 | $this->posts = 'main_wp_' . 'posts'; $this->users = 'main_wp_' . 'users'; $this->categories = 'main_wp_' . 'categories'; $this->post2cat = 'main_wp_' . 'post2cat'; $this->links = 'main_wp_' . 'links'; $this->postmeta = 'main_wp_' . 'postmeta'; $this->usermeta = 'main_wp_' . 'usermeta'; $this->terms = 'main_wp_' . 'terms'; $this->term_taxonomy = 'main_wp_' . 'term_taxonomy'; $this->term_relationships = 'main_wp_' . 'term_relationships'; |
…where ‘main_wp_’ is the table prefix you chose for you main blog. If it isn’t obvious; What we’re doing is to tell the slave blog to get most of its info from the main blogs database tables. “Mirroring” it so to speak. Most of of the info, but not all, so we can still run separate designs and more importantly; Separate plugins. But hold your horses. There’s more hackery to be done.
Step three:
Now it’s time to do a little(!) bit of MySql magic. What we need to do is to grant the admin user from the main blog the same privileges on the slave blog. So in whatever interface you run MySql do like so:
1 |
This should fix you up with two mirrored blogs on two different domains and with unique designs. It’s all downhill from here.
Step four: Download this plugin that will allow you to hide entries based on what categories they are in. The way I use this on my blogs is:
- I post everything in unitedstatesofmartin.net
- Everything I post is in one of three categories: United States(US), Sleep Furiously(SF) or Parallax Denigrate(PD).
- ctrloptcmd.com shows posts from the US and PD categories.
- sleepfuriously.net shows posts from the US and SF categories.
- unitedstatesofmartin.net shows all the posts.
Hence; I can post to one, two or all of my blogs. Yippie! Now… Beware, there are some pitfalls. One of them is that the posts from the hidden categories will show up on “Recent Posts” widgets and the like. I’m looking into this. Also I’m fairly certain that more stuff will jump up and bite me in the ass, and If so I’ll keep you posted.
There are 10 comments in this article: