Skip to content

Instantly share code, notes, and snippets.

@darrenjaworski
Created August 8, 2016 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrenjaworski/d7a380f6a3866bd08f30f661b9473a7c to your computer and use it in GitHub Desktop.
Save darrenjaworski/d7a380f6a3866bd08f30f661b9473a7c to your computer and use it in GitHub Desktop.
wp config database conditional
<?php
// ... An alternative to a multisite config while using the same codebase.
// ... In my use case: parent and child theme with two different domains. Multisite not wanted. (although it would make life easier)
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
$domain_one = preg_match( '/domainone\.com/', $_SERVER['SERVER_NAME'] );
$domain_two = preg_match('/domaintwo\.com/', $_SERVER['SERVER_NAME'] );
if ( $domain_one ) {
define('DB_NAME', 'database_one');
} else if ( $domain_two ) {
define('DB_NAME', 'database_two');
}
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment