Skip to content

Instantly share code, notes, and snippets.

@vincentmilliken
Created December 19, 2012 10:36
Show Gist options
  • Save vincentmilliken/4335829 to your computer and use it in GitHub Desktop.
Save vincentmilliken/4335829 to your computer and use it in GitHub Desktop.
Small Wordpress snippet
just before the comment that says /* That's all, stop editing! Happy blogging. */
// Assuming WP is in the root folder, adjust if not
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/wp-content');
$domain = $_SERVER[HTTP_HOST];
if ($domain === '') : // If is live enviroment
define('DB_NAME', 'our_live_db');
define('DB_USER', 'our_live_user');
define('DB_PASSWORD', 'our_live_password');
define('DB_HOST', 'localhost');
elseif () : // If is staging enviroment
define('DB_NAME', 'our_staging_db');
define('DB_USER', 'our_staging_user');
define('DB_PASSWORD', 'our_staging_password');
define('DB_HOST', 'localhost');
elseif () : // If is first developers local enviroment
define('DB_NAME', 'first_env_db');
define('DB_USER', 'first_env_user');
define('DB_PASSWORD', 'first__env_password');
define('DB_HOST', 'localhost');
elseif () : // If is second developers local enviroment
define('DB_NAME', 'second_env_db');
define('DB_USER', 'second_env_user');
define('DB_PASSWORD', 'second__env_password');
define('DB_HOST', 'localhost');
else () : // If none, fallback to these
define('DB_NAME', 'fallback_db');
define('DB_USER', 'fallback_user'); // Usually 'root'
define('DB_PASSWORD', 'fallback_password'); // Usually 'root' too
define('DB_HOST', 'localhost');
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment