0

I need to move my simple Wordpres site from www.mysite.oldplace.com to www.oldplace.com in most as possible simple and native way. My simple site specification: WP 4.4.2 Twenty Twelve 1.9 theme Polylang plugin 1.8.4

I know that I can install some plugins that might do this job, but I'm not sure they really does this job well. I have heard something regarding searching and replacing site name in SQL backup/restore script. But I beleave that in our days this somehow should be solved with native WP tools. Please, describe me les paint full approach to this problem.

2 Answers 2

1

Unfortunately there's nothing native in WordPress to handle searching and replacing your domain name across all your posts, options, etc.

The closest you can get is WP-CLI's search-replace command. It's not an official WordPress project, but it has quite a high adoption rate, it's very well maintained and available by default or on demand on many hosting platforms:

wp search-replace 'http://old-site.org' 'http://new-site.org'

Another popular option is this database search and replace script which, just like WP-CLI, correctly handles serialized data, which is important for WordPress because many options and meta values are stored as serialized arrays.

0

You are probably going to need to copy everything to the new domain first if your host uses separate folders for sub domains. The least painful way of doing this is directly on the database, provided you are comfortable using phpmyadmin. You can find and replace on each table using a mysql query and the query option in phpmyadmin:

update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');

examples:

update wp_options set option_value = replace(option_value,'mysite.oldplace.com','oldplace.com');

update wp_posts set post_content = replace(post_content,'mysite.oldplace.com','oldplace.com');

update wp_postmeta set meta_value = replace(meta_value,'mysite.oldplace.com','oldplace.com');

The above queries should take care of the basic requirements to move your site. Plugins that create their own tables will need to edited in your wordpress backend.

3
  • Serialized data in option values and meta values will not be replaced correctly with this approach unless the source and destination domains have the same length.
    – kovshenin
    Commented Apr 3, 2016 at 15:34
  • Wordpress does not serialize data in the tables that will change the site name and links in content. The problem would be with plugin data and therefore should be edited in the backend manually. Unless you have a lot of plugins this would still be the simplest way for a non dev. Commented Apr 3, 2016 at 15:56
  • 1
    Yeah, that's the assumption many people make and then wonder why their widgets are broken after a "simple" search and replace :) The OP asked for the less painful approach. Well, less "paint" actually, but you get the point...
    – kovshenin
    Commented Apr 3, 2016 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.