Title: Two WordPresses, One Database
Last modified: August 31, 2016

---

# Two WordPresses, One Database

 *  [helbetica](https://wordpress.org/support/users/helbetica/)
 * (@helbetica)
 * [9 years, 12 months ago](https://wordpress.org/support/topic/two-wordpresses-one-database/)
 * Hi
    Most tickets about this topic, are EXTREMELY old; and most of the solutions
   provided by users imply **not being able to update the WP core**. [Example](https://wordpress.org/support/topic/2-sites-1-db-possible?replies=15)
 * **Has someone tried this solution?**
    [Running a Development Copy of WordPress > Two WordPresses, One Database > Using a Drop-In](https://codex.wordpress.org/Running_a_Development_Copy_of_WordPress#Using_a_Drop-In)
 * I would like mi localhost WP to use the same DB of my remote WP Site

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [helbetica](https://wordpress.org/support/users/helbetica/)
 * (@helbetica)
 * [9 years, 12 months ago](https://wordpress.org/support/topic/two-wordpresses-one-database/#post-7441449)
 * Dear WP Developer Diary
    LOL, just kidding!
 * Hi everyone
    So far, I’ve done these steps and **my attempt failed**:
 * – donwloaded remote DB
    – imported **remote** db to my http://**localhost**/phpmyadmin/(
   same name) – created same remote db user at localhost phpmyadmin, and GRANTed
   priviledges – backed up my local wp-config.php file (pointing to the original
   working db) – updated wp-config.php variables to **reflect the remote settings**:
   define(‘DB_NAME’, … define(‘DB_USER’, … define(‘DB_PASSWORD’, … define(‘DB_HOST’,‘
   localhost’); define(‘DB_CHARSET’, …
 * – created the wp-content/db.php (below the code)
 *     ```
       <?php
   
       // paste this in a (new) file, wp-content/db.php
       add_filter ( 'pre_option_home', 'test_localhosts' );
       add_filter ( 'pre_option_siteurl', 'test_localhosts' );
       function test_localhosts( ) {
       	// intercept these options
       	if ($option == "siteurl" || $option == "home") {
   
       		// test localhost
       		$http_host = $_SERVER['HTTP_HOST'];
       		echo $http_host;
       		if (strpos($http_host, 'localhost') !== false) {
       		    return "http://localhost:8080/my-local-website/_wordpress/";
       		}
   
       	}
       	else return false; // act as normal; will pull main site info from db
       }
       ```
   
 * **So far attempt failed!**
    Localhost wp copy redirects me to remote wp site.
   Tested php [strpos](http://php.net/manual/en/function.strpos.php) function on
   a different file and return true on checking if my server HTTP_HOST has the string/
   word ‘localhost’ on it
 * Any help, it will be kindly appreciated!
    Tks
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [9 years, 12 months ago](https://wordpress.org/support/topic/two-wordpresses-one-database/#post-7441483)
 * Take a look at [http://versionpress.net](http://versionpress.net)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Two WordPresses, One Database’ is closed to new replies.

## Tags

 * [one database](https://wordpress.org/support/topic-tag/one-database/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * Last activity: [9 years, 12 months ago](https://wordpress.org/support/topic/two-wordpresses-one-database/#post-7441483)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
