Two WordPress Sites, Two Themes, One Database

I posted this over on the WP forums to no avail. I also see a similar question here in March, but I don't want that solution, because it is essentially two databases:  Here goes:

We are renovating our website. it is a complete over haul of the UI, wrapper, theme etc. we are doing this in a different domain-dev.url and /home/devmhydomain/ folder on the linux server. So, it's on the same box and can access the same MYSQL.

I am trying to work out a strategy that will allow us to proceed with the WordPress development on the new site, but continue to use the same database, so that the blog archives will be up-to-date when we go live on the new site. I am pasting below a final "solution" posted on a six-year old thread on the Word Press Forums to see what anyone  thinks about it.

"Two Sites, Two Themes, One Database"

it seems a bit dicey... but it could work.

My developer says another option would be to install the new WP site on our site where we are doing all the development, give the new WP have it's own new database and then export, migrate and import the old database into the new database. The problem is: any posts in the interim between then and when we actually go live, will not have been migrated (could be a month or more of posts)

Another strategy could be to develop the new theme on the old site. then when we go live I just copy the blog folder overand just change the themes to make the one that is in development the "live" theme. The top level domain URL will not change, so it should work..

My problem is that I have a different structure for the paths to CSS and JS files... I'm not sure that's a big issue because on the old site I could set up a /assets/css /assets/js to match the new site and then the new theme would point to those instead of the current top level /css and /js folders... This seems safest... I think you can develop new themes in WP with private url's right?

OR: i could try this thing below where they suggest duplicating the wp_options table and give it a new prefix and the new site/dev domain, which will be up and running with the same database/archives.. then if someone posts on the old site, it automatically begins appearing on the new site.

my main developer is worried and cautions: "We have to be careful. I don't know what will happen if you install a new version of Word Press on the dev site and point to the same database, if it updates the database in some way that will break the old Word press installation, then the blog will die on the old site."

That's his worry and it's probably a good one.

I would appreciate any advice on "best strategy" here. I really would like to use the same dBase if at all possible. As all the migration, export, import and missing interim posts looks like pain.

Old thread which was closed six years ago:



someone wrote:

I've done this before, having 6 websites shoot out content from the same database.

It's easy enough to do. Upload WP into both directories. Make sure they have the identical wp-config.php file.

In the second sites directory do the following:
In the wp-settings.php file change the options database value to something like this:

// Table names
$wpdb->posts = $table_prefix . 'posts';
$wpdb->users = $table_prefix . 'users';
$wpdb->categories = $table_prefix . 'categories';
$wpdb->post2cat = $table_prefix . 'post2cat';
$wpdb->comments = $table_prefix . 'comments';
$wpdb->links = $table_prefix . 'links';
$wpdb->linkcategories = $table_prefix . 'linkcategories';
$wpdb->options = 'YOURNEWPREFIX_options';
$wpdb->postmeta = $table_prefix . 'postmeta';
$wpdb->usermeta = $table_prefix . 'usermeta';

$wpdb->prefix = $table_prefix;

See how I've removed $table_prefix . in the options line?
Instead of YOURNEWPREFIX put something like 'site2' or whatever you want.

Then, in PHPmyAdmin duplicate the wp_options table, and rename one of the them to be YOURNEWPREFIX_options, so if you chose 'site2', it would be 'site2_options'.

Bingo. Edit the information in the 'site2_options' table to refelct the correct information for your second site and you will be on your way.


so i am thinking to try this approach,  if I

a) use the exact same version of wordPress in both domains
b) do not do any posting from the new domain,
c) just stick to developing the theme.

will it work? That solution is six years old so i don't know whether a single installation of WordPress now has many more dependencies in the database beyond just the wp_options table.

Any thoughts?
Who is Participating?
Jason C. LevineNo oneCommented:
Aloha, Jason (I live in Hawaii)


How is this done?

Talk to your developer if you aren't familiar with the more arcane functions of mysql.

Basically, the Federated storage engine allows to have a table synchronized across MySQL databases and the data is live.  So changes to the table in site A instantly update in site B and vice-versa.  The end result is two wordpress sites with two different databases but the content table (wp-posts) is shared between them.
Jason C. LevineNo oneCommented:
You can easily point two installations of WordPress to one database but two themes with different file paths is not going to work all that well.

The solution posted above regarding the wp_options table might work but it will also affect plugins and permalinks and some other stuff.  Assuming you go very slow and test at each step, I could see it working.

I would actually consider a different path: just federate or replicate the wp_posts table between the two WP databases.  That will keep the content synced and allow complete customization of all other WP elements.
SivakatirswamiAuthor Commented:
Aloha, Jason (I live in Hawaii)

I like your proposal, but it's a bit over my head.

"just federate or replicate the wp_posts table between the two WP databases."

1. How is this done? I'm not a MySql expert other than being able write queries, and use ALTER to change some fields, my knowledge ends about there.

2. would this mean that we have to post the same article twice each time it is done? (my users will never do that!)
SivakatirswamiAuthor Commented:
Oh wow... better than mangos and fromage blanc from our own trees and cows! We will try it.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.