For hosting wordpress site from localhost to live server require to change all the localhost urls to the live domain urls. Done and site also loads fine but none of the media items are showing as they are inside base encoded strings.
BUT How to replace urls inside the base encoded strings saved by the theme and other plugins?
In my case i am using BeTheme and visual composer which contains the actual page content and saved base encoded in the db.
They contains the hardcoded full urls of a lot of media items.
I took the db dump in a .sql file and find and replaced all localhost to live domain url… But this is where i stuck!
I encountered the same problem and found a way to do this.
My example is for wp_postmeta table and some theme from Muffin
Requirements:
Steps:
Backup your database(!!!)
Create a table with same layout as wp_postmeta:
Insert into new table base64_decoded values selected from wp-postmeta
Use search-replace plugin in wp to replace “domain.net” with “domain.com” in
wp_base64_dec
table .Replace the altered columns in the original table:
The short answer is: you can’t. Visual Composer, in an attempt to be helpful, base64 encodes URLs in the database. Search and replace (including wp-cli’s version) doesn’t work on these. It’s a huge limitation, and WPBakery is aware of it–but hasn’t offered a solution.
For some reason, after applying @frater_sourcecode answer I got unserializing error, probably because the specified length of a string doesn’t match once we do a URL replace.
There’s an official Muffin Builder URL replace tool.
https://muffingroup.com/plugins/mfn-migrate-cb.zip
This is a WordPress plugin.
I’m not sure why it’s not mentioned anywhere, but I found it on Reddit.
Source
Thanks to @frater_sourcecode for the perfect solution.
I adopt it for WPML plugin which does not respect RELOCATE directive.
Here is the code:
(!! –dry-run I use only for demo here !!)
if you export your database from phpmyadmin then you want get serialized data.
you have to use plugin to get export.
wp migrate db is a great plugin for this you.
https://wordpress.org/plugins/wp-migrate-db/