Ck Tam
Ck Tam

Reputation: 11

How to change image url on all pages after migration with out using a plugin in wordpress?

After migration, all of images on pages (about-us, artists etc) are not showing I have to manually change them just like what I did on the home page. I have tried different plugin such as velvet blues and search and replace but it couldn't change the images on pages by automatic instead i have to do them manual which would a lot of time.

Here's what I like to happen with all the image tag on all pages, I want the url http://cjdrafts.info/quadrantgallery to change to http://cjdrafts.info/art

<img  src="http://cjdrafts.info/quadrantgallery/wp-content/uploads/2016/04/237715.jpg" align="center" />

change to

<img  src="http://cjdrafts.info/art/wp-content/uploads/2016/04/237715.jpg" align="center" />

I have been changing urls manually on all of my other drafts after migration for all pages so it will be great if someone can teach me how i can do it automatically.

THanks in advance.

Upvotes: 0

Views: 1722

Answers (1)

A. Campbell
A. Campbell

Reputation: 414

1.) I understand that you've said that you don't want to use a WordPress plugin, but if possible you really ought to checkout better search replace it should do exactly what you're describing.

2.) You could run this SQL code in your database management system:

UPDATE wp_options SET option_value = replace(option_value, 'http://cjdrafts.info/quadrantgallery', 'http://cjdrafts.info/art') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://cjdrafts.info/quadrantgallery','http://cjdrafts.info/art');

UPDATE wp_posts SET post_content = replace(post_content, 'http://cjdrafts.info/quadrantgallery', 'http://cjdrafts.info/art');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://cjdrafts.info/quadrantgallery','http://cjdrafts.info/art');

Upvotes: 2

Related Questions