Develop and Work with WordPress Multisite Locally Using a Production Database

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.

Use Contact Form 7 to collect business leads and enquiries? I created Storage for Contact Form 7 plugin which stores them safely in WordPress database.

Get it now for only $19 →

4 Comments

  1. Ryan Hellyer says:

    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.

  2. Kaspars says:

    I knew you might like this, Ryan :)

  3. Jonathan says:

    Neat trick, will definitely use it next time around. Thanks!

  4. Bart says:

    Worked perfectly thanks!

Leave a Reply