How to run Two WordPress blogs with different themes and with single database and same content

I’ll try to explain how it might be done, but not sure it will work:

  1. Install 2nd website with single db (2 copies).

  2. Create new table in your db. Call it wp_options2 and copy everything from wp_options into the new table

  3. in second install in wp-config.php, before if ( !defined('ABSPATH') ) add

    define( 'M7_OPTIONS_TABLE', 'wp_options2' );
    
  4. in second install go to wp-includes/wp-db.php on line 1054(for WP 5.6) and add this code:

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

    (This code should be added to the public function tables function, before if ( isset( $tables['users'] ) && defined( 'CUSTOM_USER_TABLE' ) ) )

Now you should be able to change the theme, plugins atc. for the second theme, but all posts, taxonomies etc. will be doubled in both websites (wich is bad for seo btw.)

Should you run into problems with links on your second install, add:

define('WP_HOME','http://seccond_website.com');
define('WP_SITEURL','http://seccond_website.com');

in your wp-config.php file …..

but it wouldn’t solve the problem if you were to create some post on the 1-st website, on the second website it would link to the first website…

I’ll still post this answer, even though it’s not correct (because of the problem described above).

As a solution you could create 2 separate installs with different $table_prefix and add an action to each move (save_post, save_taxonomies, save_postmeta etc.) to save from 1 db to the other, but changing the necessary links.

Or you could create a cron job on the second install to parse every post, page etc from the 1-st db to the 2-nd (since you have the access to both of them, it would be easy)

Leave a Comment