I am using WordPress 3.5.2. I need to have two websites with the same content (plugins/users/posts/pages etc) but different theme. Already tried several ways to achieve that but with no results. I used the same database for both wp websites. When I login to the website1 everything is normal. Every change I make, affects both 1st and 2nd website. When I login to the website2 it redirects to the 1st website's dashboard. Some of you may say I should use WPMU but unfortunately this is not an option for what I need to to.

The above way looked closer to me but didnt work: Editing wp-db.php

Also have read and tried everything I found here on wp stackexchange...

  • Could you explain us what did you do to have this result ? Or maybe what you are describing here is the intended behavior, not the one you have right now ? – Fabien Quatravaux Jun 30 '13 at 23:03
  • Did you try switch_to_blog function ? – Fabien Quatravaux Jun 30 '13 at 23:06
  • I can't think of any reason why you would want to have 2 duplicate web sites oin the same database but to get rid of the redirect you should be able to login to both using google incognito mode. – Wyck Jun 30 '13 at 23:09
  • @FabienQuatravaux This is what came out, not the intended behaviour. I tried differend prefixes, the solution in the link (editing wp-db.php) and what other people suggested in stackoverflow on other posts. WYCK the problem is not to change the theme once, but to make it work properly. – ArgGeo Jun 30 '13 at 23:19
  • 1
    Changing core files is a really bad idea, having 2 sites on the same database is also a bad idea, and your comment makes no sense, logging into wordpress has nothing to do with a theme. – Wyck Jul 1 '13 at 4:22

What I would do is to use switch_to_blog function just before posts queries are run on the database, and then restore the current blog just after the query.

I assume that the blog where your content is is the main one (1). Just put the following lines in your second blog theme's function.php :

add_action('pre_get_posts', 'user16975_get_content_from_other_blog');
function user16975_get_content_from_other_blog(){

add_filter('the_posts', 'user16975_restore_initial_blog');
function user16975_restore_initial_blog($posts){
    return $posts;

This should work for both back- and front-ends. Be careful to test this fully before using, because it could have unintended behaviors. For example, all the settings used for the second blog are taken from the second blog database, so they might be different from the main blog.

  • Fabian thanks for answering but it is not just the blog if I understand correctly what you mean... I have custom post types, woocommerce and other things running on the website... I believe the solution you suggest won't do the trick, right? – ArgGeo Jul 1 '13 at 0:07
  • This solution will work for custom post types (they are just posts in fact) but not for plugins. However, you can either activate manually the same plugins on both blogs (blog = site in WP terminology), or add another action (on activate_plugin) that keeps activated plugins in sync. And what do you mean exactly by "other things" ? There should be a solution like this for other things. – Fabien Quatravaux Jul 1 '13 at 0:16
  • Will woocommerce with subscriptions extension sync between both websites? – ArgGeo Jul 1 '13 at 0:22
  • Have you tried ? It depends on the way WooCommerce stores and retrieves the values on the database. With my method, all database access using WP_Query should work. Please do not try this on a production environment before heavy testing. – Fabien Quatravaux Jul 1 '13 at 0:36
  • For example, Menus (defined in Apprearance > Menus) will not be the same on both sites. – Fabien Quatravaux Jul 1 '13 at 0:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.