4 ms·
> In Wordpress, the site name is baked in all over the place — in config, in database, in generated stylesheets and so on. In theory, this should not be like th
by neurostimulant 5y ago
> In Wordpress, the site name is baked in all over the place — in config, in database, in generated stylesheets and so on. In theory, this should not be like this (if you use barebones install w/o plugins), but then you buy a theme or some less-than-perfect plugin and boom, you need a separate plugin just to handle migration (which may or may not work 100% of the time).
WP-CLI is your friend:
wp search-replace 'http://example.test' 'http://example.com'
- johnchristopher 5y agoDon't do that. Wordpress store some information fields and the length of the string of those fields. Use a plugin that search and replace for those and recalculate the length. Also, search for //example.test, not http://example.test http://example.test. Edit: I read a bit too fast, maybe it does implement the string size but I can't be sure https://github.com/wp-cli/wp-cli/issues/1224 https://github.com/wp-cli/wp-cli/issues/1224 Edit 2: https://github.com/wp-cli/wp-cli/pull/1261 https://github.com/wp-cli/wp-cli/pull/1261 sweet, looks like it does ^^.
- mpol 5y agoAs far as I know WP-CLI also handles serialized data correctly. By the way, I very much prefer the wpmigrate-db plugin.
- johnchristopher 5y agoAlso, wpmigrate-db has wp-cli commands to export the database, I don't know if wp-cli search-replace can do that. Edit: And it does: [--export[=<file>]] Write transformed data as SQL file instead of saving replacements to the database. If <file> is not supplied, will output to STDOUT. Well, wpmigrate-db allows to replace multiple strings in one command and that's something wp-cli default search-replace doesn't provide.