WordPress: Bulk URL change from SQL

Let's "talk" about WordPress. After of ς of iguru.gr in the iguru base, all the links of the images pointed to the directories of iguru.gr. For example:

wordpress-code

https://cdn.iguru.gr/wp-content/uploads/2016/10/Mechanic.jpg

So even though there were posts in iguru the images kept coming from iguru. So after transferring all the files from iguru / uploads to the iguru dir of the same name, we had to change the URLs en masse to get the images from:

https://cdn.iguru.gr/wp-content/uploads/

Let's see how easy it is (before you try it, make one in your database):

Below are the SQL which we used to change the URLs throughout the database.

UPDATE wp_options SET option_value = replace (option_value, 'https://iguru.gr/wp-content/uploads/files',' https://iguru.gr/wp-content/uploads/files') WHERE option_name = 'home 'OR option_name =' siteurl ';
UPDATE wp_posts SET guid = replace (guid, 'https://iguru.gr/wp-content/uploads/files','https://iguru.gr/wp-content/uploads/files');
UPDATE wp_posts SET post_content = replace (post_content, 'https://iguru.gr/wp-content/uploads/files', 'https://iguru.gr/wp-content/uploads/files');
UPDATE wp_postmeta SET meta_value = replace (meta_value, 'https: //iguru.gr/wp-content/uploads/files','https: //iguru.gr/wp-content/uploads/files');

iGuRu.gr The Best Technology Site in Greecefgns

every publication, directly to your inbox

Join the 2.087 registrants.

Written by giorgos

George still wonders what he's doing here ...

Leave a reply

Your email address is not published. Required fields are mentioned with *

Your message will not be published if:
1. Contains insulting, defamatory, racist, offensive or inappropriate comments.
2. Causes harm to minors.
3. It interferes with the privacy and individual and social rights of other users.
4. Advertises products or services or websites.
5. Contains personal information (address, phone, etc.).