Update: This is useful only if you can’t edit your local /etc/hosts
file (using a tool like Gas Mask makes it fast and super easy) and use the production domain for development.
To my knowledge, there was no way to work on a WordPress Multisite network locally while using a production database, so I spent a few hours and created a simple MU plugin which allows you to do just that.
The way Multisite Local Dev works is it filters all get_option
and get_site_option
calls for siteurl
and home
values to correct the site URLs. In addition, we define both $current_site
and $current_blog
globals already in wp-config.php
to stop WordPress from querying database for these variables in wp-includes/ms-settings.php
, which is the key to this solution.
Currently this works only with sites in sub-folders, but it should be relatively easy to modify it for either subdomains or separate domains.
I don’t think sub-folder vs domain and sub-domain issue would be a problem so long as you are using a domain mapping plugin on your local install.
Good work btw, I didn’t think this would be possible.
I knew you might like this, Ryan :)
Neat trick, will definitely use it next time around. Thanks!
Worked perfectly thanks!