When we migrate from our local development environment to our production we make a database search and replace something like this (it works great):
UPDATE wp_options SET option_value = replace(option_value, 'http://oldurl.com', 'http://newurl.com') WHERE option_name = 'home' OR option_name = 'siteurl' OR option_name = 'favicon' OR option_name = 'background_login' OR option_name = 'logo_login'; UPDATE wp_posts SET guid = replace(guid, 'http://oldurl.com','http://newurl.com'); UPDATE wp_posts SET post_content = replace(post_content, 'http://oldurl.com', 'http://newurl.com'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://oldurl.com','http://newurl.com');
The code above has always worked fine until we started to use the acf-field “link” (https://www.advancedcustomfields.com/resources/link/). The field itself is awesome but when we migrate the serialized data contains the URL’s length and this is a huge problem when we change from development enviroment to production.
When the domain changes, so does the length of the string and therefore the information is gone on our production server.
How can we migrate in a better way to keep our data? We would love to be able to keep working with this awesome field.
Thanks in advance!
The best way, is to use the command line interface for WordPress:
Here are the options and arguments to use for search and replace:
After I started this thread I also found this plugin (https://sv.wordpress.org/plugins/wp-migrate-db/) that works great!
You can easily replace the current database, or export it and do whatever you want. So far I have not had a single issue with it.
Can highly recommend it! 🙂
The problem is that this field is stored as a serialized array. Many plugins save data as serialized arrays. It is unsafe to do simple find and replace on this type of data and you must use a tool that does this correctly and the one mentioned is the only one I know of that does it well.
To understand it further we’d need to go into a detailed explanation of what serialized data is and how it’s formatted, and there are better sources for that information than me.
Sorry from me too then, because this morning I thought I was replying to @babelfish99 and then now I was making a reply to you @hube2 but the forum don’t seem to show that it’s a actual reply, it is visible just as a ordninary post.
Thanks for your time anyway. Hope my answer (to use the plugin I linked to above) works for other guys than just me! 🙂
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Sorry for the issues with ACF's API SSL certificate this morning. We've resolved it and your activations and downloads should be back to normal again. Thanks! ^LG— Advanced Custom Fields (@wp_acf) November 2, 2022
© 2022 Advanced Custom Fields.