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:
CREATE TABLE wp_base64_dec LIKE wp_postmeta
Insert into new table base64_decoded values selected from wp-postmeta
INSERT INTO wp_base64_dec(`meta_id`, `post_id`,`meta_key`,`meta_value`)
SELECT `wp_postmeta`.`meta_id` AS `meta_id`,
`wp_postmeta`.`post_id` AS `post_id`,
`wp_postmeta`.`meta_key` AS `meta_key`,
FROM_BASE64(`wp_postmeta`.`meta_value`) AS `meta_value`
FROM `wp_postmeta` WHERE
((`wp_postmeta`.`meta_key` = 'mfn-page-items') AND
(FROM_BASE64(`wp_postmeta`.`meta_value`) LIKE '%domain.net%')) ;
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:
REPLACE wp_postmeta
SELECT
`meta_id`,`post_id`,`meta_key`,
TO_BASE64(`meta_value`) as `meta_value`
FROM `wp_base64_dec`
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With