Home Forums General Issues How to rewrite database correct for the "acf link"-field?


How to rewrite database correct for the "acf link"-field?

  • Hi,

    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, '', '') 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, '','');
    UPDATE wp_posts SET post_content = replace(post_content, '', '');
    UPDATE wp_postmeta SET meta_value = replace(meta_value,'','');

    The code above has always worked fine until we started to use the acf-field “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:

  • I’ve been having a similar issue with ACF Link. It’s such a useful field but I’ve had to stop using it because after find and replace it stops working. Looking forward to a fix for this!

  • After I started this thread I also found this plugin ( 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.

  • Exactly. WP Migrate DB works great for this. Serialized data is tricky to replace by yourself. 🙂

    This thread can be marked as solved if that’s possible.

  • sorry @henricakesson I was replying to @babelfish99 (and anyone else that happens on this topic) to give a basic explanation of why simple search and replace on the db does not work.

    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! 🙂

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.