Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have created a site and would like to create another version of the same site using the same exact database (db location, users, everything). The two sites would share one database. I already have one site created and wanted to know how feasible it is to do, and instructions on how to do it.

Currently, the site up now is for consumers and the other version will be for corporate clients. Please give me some advice on how to do this.

The site is: www.savingsulove.com

Thanks a lot for the help.

share|improve this question
    
I don't think it would work for the two sites to share a database. Actually, I'm nearly certain it wouldn't - that wouldn't really make any sense, unless you want the two sites to be identical. –  tnorthcutt Feb 25 '11 at 20:56
add comment

2 Answers

up vote 5 down vote accepted

Hi @user1893:

There are a couple of ways you can achieve what you asked for but the latter is what I'd recommend:

  1. Set up a copy of the site in a different directory and using your web host's control panel map the different domains to the appropriate directories. Use the same DB_NAME/DB_USER/DB_PASSWORD/DB_HOST in the /wp-config.php file for each of your sites but include different defines for WP_HOME and WP_SITEURL in each file. You might run into a few glitches but I think you can work through them by asking more questions here on WordPress Answers.

  2. Use one site with two different themes, add logic in /wp-config.php to recognize the different domains, and various hooks you might need to get things to behave as you want especially including one to load the right theme. What follows is (some of?) the code you'll need for option #2.

Using One Site with Two Different Themes:

This code goes in your /wp-config.php file anywhere before require_once(ABSPATH . 'wp-settings.php');:

$this_domain = $_SERVER['SERVER_NAME'];
switch ($this_domain) {
  case: 'www.savingsulove.com':
  case: 'www.savings4biz.com': // I made up this domain to enable this example              
    define('WP_HOME',"http://{$this_domain}");
    define('WP_SITEURL',"http://{$this_domain}");
  default:
    echo 'Invalid domain';
    die();
}

Then to switch the theme based on the domain use the template hook with the logic below. Probably the best place to put this code would be in a "Must Use" plugin; i.e. put the following into /wp-content/mu-plugins/savingsulove-theme-switcher.php. This code assumes you've got two themes in the respective subdirectories /wp-content/themes/savingsulove/ and /wp-content/themes/savings4biz/.

/*
File Name: savingsulove-theme-switcher.php
Plugin Name: Switch the Theme Based on Domain
*/
add_action('template','savingsulove_template');
function savingsulove_template($template) {
  if ($_SERVER['SERVER_NAME']=='www.savingsulove.com')
    $template = 'savingsulove';
  else
    $template = 'savings4biz';
  return $template;
}

Beyond that, you can add any other shared code as a "Must Use" plugin like above (or just add more code to the savingsulove-theme-switcher.php file) where you just inspect the value in $_SERVER['SERVER_NAME'] to decide what to do. If you need help with any additional aspects that might occur, just ask another question here (as opposed to adding follow up questions in the comments on this page after this question has been answered.)

P.S. There are more maintenance-free ways I could have written the above code but then it would have been more obscure and harder for a reader new to the techniques to follow what I was doing.

share|improve this answer
    
Thank you so much. I'll take your first suggestion. It should not be hard based on your instructions, but "should" is a deceitful word so I will let you know how things turn out or ask more questions on the site. Again thank you. –  user1893 Feb 28 '11 at 16:08
    
@user1893 - Let us know how it worked in the comments, or if you have other questions. –  MikeSchinkel Feb 28 '11 at 19:00
add comment

There is not quite enough specific of what you have planned to suggest best approach.

For example:

  • you can load different templates (or themes altogether) for different parts of single site;

  • you can create multisite installation and have two sites running of single WP core;

  • you can override user handling so two separate sites use same source for that;

  • etc...

share|improve this answer
    
@Rarst: The plan for the two sites is that one will be for general businesses listing their offers and coupons for consumers to view. And the other site will be targeted to more professional type business (Doctors, lawyers, etc), that won't necessarily have a coupon but will like a more dignified look and list their offers to consumers as well. Do you think the multsite install would be best or is there something else you suggest? Thanks for the input –  user1893 Feb 25 '11 at 20:47
    
@user1893 how do you see URL structure for it? Same domain? Different domains? –  Rarst Feb 25 '11 at 20:53
    
I would prefer the urls to be separate, especially the website domains. –  user1893 Feb 25 '11 at 21:16
    
@user1893 well, then you will likely need multisite with domain mapping. Likely won't be easy or worth it to use different domains with single site. –  Rarst Feb 25 '11 at 21:23
    
I have to go through the link you provided. Is it difficult for setup a multi install? –  user1893 Feb 25 '11 at 21:25
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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