Subscribe via RSS

Migrated WordPress database; Theme mods are gone!

This was fun... I just helped a friend migrate their database. The DB export and import was fine; just don't try and paste the SQL into the query window all at once... go to the import page on PHPMyAdmin and upload it there!

Meanwhile, once uploaded, all the custom settings on the themes (it inherited from a base theme) were lost! I watched the database and the fields were actually reset! There must have been an error parsing the data. It has to be noted that I had to change data in the database during the migration. As that I was changing from one domain to another, the hard-coded URLs needed to be migrated.

In the source database, the row in the wp_options table with key 'theme_mods_Divi' looked like this:


I don't know what the first a:8 stands for, but all the s values inside mean string, followed by the length, then the data.

I actually, as a migration task, had to change the strings from one URL to another (as part of the domain shift.) Turns out that when you do this, if the URLs being replaced aren't the exact length, then the string lengths will change .... of course, this is obvious now .... WordPress was then trying to parse the values and overrunning/underrunning the values. In the end it just gives up and resets the custom mods.

So, when changing the strings, you need to change something like:




...the key being that you've adjusted the length to the new variable.

Once this is done: drop all the tables, re-import them via the script and WordPress should then load the mods correctly! I hope this prevents at least one other person from wasting the 2 hours that I just did. Never lose your custom theme settings/mods when migrating ever again!

Comments (0) Trackbacks (0)

No comments yet.

Leave a comment


No trackbacks yet.