Multiple Blogs From Single WP Installation

Posted: 17th November 2009 by Jaygovind Sahu in WordPress
Comments Off

When I thought of making a test-website for my school in one of subdomains which was again planned with wordpress, I thought whether I could use the wordpress core files installed for this blog be used for that subdomain. I found several solutions. I found a plugin WP-Hive which did not work well for me. And then I found another way which includes changing the wp-config.php file to following: (adding the php tag at the beginning)


// ** MySQL settings ** //
define('DB_NAME', ''); // The name of the database
define('DB_USER', ''); // Your MySQL username
define('DB_PASSWORD', ''); // ...and password
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value

// table prefix, for hosting multiple installtions in the same db.
$table_prefix = ereg_replace('^(www.)', '', $_SERVER['HTTP_HOST']);
$table_prefix = ereg_replace('.', '', $table_prefix);
$table_prefix = $table_prefix . '_';

// Change this to localize WordPress. //
define ('WPLANG', '');

/* Stop editing */

define('ABSPATH', dirname(__FILE__).'/');
require_once(ABSPATH.'wp-settings.php');
?>

It can be noted that this file sets the table prefix related to the url. So, any url which points to the main wordpress installation is allowed to make a new blog for itself. There is one problem in this solution though – when you use many number of blogs the list of tables becomes very big.

Comments are closed.