Skip to content

Instantly share code, notes, and snippets.

@rutger1140
Last active July 4, 2016 17:40
Show Gist options
  • Save rutger1140/4546397 to your computer and use it in GitHub Desktop.
Save rutger1140/4546397 to your computer and use it in GitHub Desktop.
Run 2 copies of WordPress from the same database. Put this in your wp-config.php file above the line require_once(ABSPATH . 'wp-settings.php');
<?php
/** Run 2 copies of WordPress from the same Database
*
* source: http://codex.wordpress.org/Running_a_Development_Copy_of_WordPress#Run_2_Copies_of_WordPress_from_the_same_Database
*/
function WP_LOCATION () {
$script_path = realpath(dirname($_SERVER['SCRIPT_FILENAME']));
$wp_base_path = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR);
$web_subfolder = substr( $script_path, strlen($wp_base_path));
$wp_path = $web_subfolder ? substr( dirname($_SERVER['SCRIPT_NAME']), 0, -strlen($web_subfolder) ) : dirname($_SERVER['SCRIPT_NAME']) ;
$retval = 'http' . ($_SERVER['HTTPS'] ? 's' : null) . '://' . $_SERVER['HTTP_HOST'] . $wp_path ;
return $retval;
}
$wpLocation = WP_LOCATION();
define('WP_HOME',$wpLocation);
define('WP_SITEURL',$wpLocation);
define('WP_CONTENT_URL',$wpLocation."/wp-content");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment