Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WordPress Workflow with remote DB on local
//Working on a WordPress theme with others can be difficult if you want to use the same database, but work locally and use git for the code.
//To do this we came up with a solution that allows working with a remote DB that everyone on the team can access, while still developing locally.
//First make sure that your wp-config file is set to use the remote db:
//set the credentials for the remote DB username and table
//change DB host to be the ip of the remote server
define( 'DB_HOST', '123.45.678.195' );
//Now make sure the home url is set to use the local version of your wordpress enviroment. We used local by flywheel.
//also make sure the admin end is using the remote site completely.
define('WP_HOME', 'http://yoursite.local'); //front end will use the local site
define('WP_SITEURL', ''); //the actual site where the database is
//lastly add this to your theme or a plugin so when viewing on local it will get your theme
//on local development load local theme instead. Everything else loads in as remote
if ( strpos($_SERVER['HTTP_HOST'], '.local' ) ) {
add_filter( 'theme_root_uri', 'ign_theme_root_uri', 10, 3 );
function ign_theme_root_uri( $theme_root_uri, $siteurl, $stylesheet_or_template ) {
//replace thew siteurl with the local siteurl from the theme uri
return str_replace( $siteurl, 'http://yoursite.local', $theme_root_uri );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.