Wordpress: Move Multisite from server to localhost

前端 未结 4 1202
情话喂你
情话喂你 2021-02-06 00:04

I am trying to move a deployed WordPress Multi-Site to a local environment. I backed up the server database and files. In my local environment, I created a new database and impo

4条回答
  •  感情败类
    2021-02-06 00:36

    Ninja's answer helped a lot. Though you can shorten the amount of the steps described in his answer by using wp-cli for database replacements, so you don't need any third party plugins and to edit single database cells manually. wp-cli's search-replace function works amazingly perfect, at least in my experience in case of usual wp sites. But in combination with the steps in ninja's answer it also has worked with multisite in my case. Here is a great description on how to install wp-cli: https://wp-cli.org

    To replace a string through out all the sites run:

    wp search-replace //oldurl.com //dev.url.test --network
    

    Yes, the url strings are not wrapped with quotes. From my experience this way the replacement works perfect without any issues which might appear using quotes.

    To replace strings in a particular site:

    wp search-replace //oldurl.com //dev.url.test --url=https://oldurl.com
    

    To see what urls are mapped to the sites:

    wp site list --network
    

    Though the db replacements worked well. I had to deactivate multisite in the wp-config.php (by removing all the multisite constant definitions) and all the plugins first and then to reactivate them from network dashboard.

    wp-cli search-replace docs: https://developer.wordpress.org/cli/commands/search-replace/

提交回复
热议问题