Skip to content
Advertisement

Two wordpress sites using diiferent themes on the same database

I want to run 2 wordpress sites, one.site.com and two.site.com from the same database. Everything remains the same except for the theme.

  • one.site.com – Existing site
  • two.site.com – Should use one.site.com’s database except for the theme

Is there any way this can be done ?

Since theme details are stored in wp_options table is it possible for two.site.com to use it to display a different theme ? Say duplicating that table and making two.site.com use it ?

I appreciate any help.

EDIT:

Both the sites do not have any plugins.

Advertisement

Answer

The solution below did the job for me,

Install 2 WordPress sites on a single database.

Create new table in your database. Call it wp_options2 and copy everything from wp_options into this new table

In second install go to wp-config.php, and before if (!defined('ABSPATH')) add define( 'M7_OPTIONS_TABLE', 'wp_options2');

In second install go to wp-includes/wp-db.php on line 1009 and add code:

if (isset( $tables['options'] ) && defined('M7_OPTIONS_TABLE')) $tables['options'] = M7_OPTIONS_TABLE;

These codes should be added in public function tables function, before if (isset( $tables['users']) && defined('CUSTOM_USER_TABLE')))

I found this solution here, https://wordpress.stackexchange.com/questions/84313/how-to-run-two-wordpress-blogs-with-different-themes-and-with-single-database-an#answer-175494

Since we use the same database, links will be same on both the sites. I had a lot of images linked and I removed them using

.single a[href$=".jpg"] {
    pointer-events: none;
    cursor: default;  
} 
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement