Multiple WordPress sites share same database

In some cases, we need to create other website using the same database for conditionally purposes. Let says, we do have www.domain.com, but we also need a different spesific site for Facebook Page fb.domain.com. Or you might need touch site (with swipe capabilty), like touch.domain.com.

After googling, here’s the tricks I found. 🙂

  1. Create a new WordPress site with subdomain (eg: fb.domain.com)
  2. Copy wp-config.php from main website to your subdomain site, and add this
    define('WP_HOME','http://fb.domain.com');
    define('WP_SITEURL','http://fb.domain.com');
    This will forced this new site to keep the domain as fb.domain.com.
  3. Now, how to make this new site use spesific template. Add this to your functions.php
    add_filter('template', 'change_theme');
    add_filter('option_template', 'change_theme');
    add_filter('option_stylesheet', 'change_theme');
    function change_theme()
    {
    // return the name of theme (theme directory name)
    return 'yourspesifictheme';
    }

Now you have another spesific site, but still using the same database.

Oops, before I forgot… You also need to add meta tag ‘noindex, nofollow’ in your header, to avoid duplicate content in term of SEO. 🙂

Leave a Reply