How do you run two WordPress blogs with different themes using one database where the content remains the same in both sites? The issue that I am getting is at the Domain mapping in both blogs.
Leave a Reply
You must be logged in to post a comment.
How do you run two WordPress blogs with different themes using one database where the content remains the same in both sites? The issue that I am getting is at the Domain mapping in both blogs.
You must be logged in to post a comment.
I’ll try to explain how it might be done, but not sure it will work:
Install 2nd website with single db (2 copies).
Create new table in your db. Call it
wp_options2
and copy everything fromwp_options
into the new tablein second install in
wp-config.php
, beforeif ( !defined('ABSPATH') )
addin second install go to
wp-includes/wp-db.php
on line 1054(for WP 5.6) and add this code:(This code should be added to the
public function tables
function, beforeif ( 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:
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)
Not sure if it will be enough but this two plugins should give you most of what you want
Any hostname – change the content urls to reflect the domain in which the content was requested
Domain Theme – change the them according to the domain name.
I haven’t tested any of them but it looks like even if they don’t work you can get useful pieces of code from them.
If you have two separate WordPress installations (one per domain), you can define
WP_SITEURL
andWP_HOME
inwp-config.php
to force a specific address/hostname. Add this code to eachwp-config.php
:And change example.com to the name of the domain in question.
Let me repeat your question in my words: you want two wordpress sites, using the same database and the same content. Just having a different theme and a different domain name?
That’s duplicate content an google will rank both your sites badly for doing so.
I highly encourage you not to do so.
If you just want to share parts. Have a look at the
switch_to_blog()
function provided by WordPress multisite.You can change the theme based on the current domain like