Skip to content

Instantly share code, notes, and snippets.

@Jursdotme
Created May 21, 2014 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Jursdotme/a6bc07da609f8a753857 to your computer and use it in GitHub Desktop.
Save Jursdotme/a6bc07da609f8a753857 to your computer and use it in GitHub Desktop.
Use Live database on local Wordpress install.
// Use live database on local installation
<?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( ) {
if (strcasecmp($_SERVER['SERVER_NAME'], '.dev') != 0 || strcasecmp($_SERVER['SERVER_NAME'], 'localhost') != 0 ) {
return "http://".$_SERVER['SERVER_NAME'];
}
else return false; // act as normal; will pull main site info from db
}
@Jursdotme
Copy link
Author

Add this (and modify as needed) to /wp-content.

Based on the technique on this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment