How to change old attachment url to new url in wordpress post

8
wordpress how to change old url to new url

WORDPRESS : OLD URL TO NEW URL

There are many tutorial available online for this topic and its easy to change Old url to New Url. All you have to learn little basic knowledge of using phpMyadmin. But i will repeat here one more time so if someone reached this post and not aware of it , he can get benefit from it.

STEP 1 :- 

Go to your phpmyadmin and open the database which is getting used for wordpress.

STEP 2 :- 

Once you click the selected database it will expand and tables under that database will appear in side base.

STEP 3 :- 

Check ” wp_options ” table click on it and change “siteurl” and “home” , that’s it. It will change domain of your old wordpress to new.

how to change url of wordpress


Above tutorial is to change your main URL of wordpress blog. But here our main concern is to change URL inside post content which is used through attachment.

So lets go to phpmyadmin again and find the table for such content and that table name is ” wp_posts ” in this table all post content are getting saved.

WORDPRESS POST CONTENT OLD URL TO NEW URL

STEP 1 :-

Click on ” wp_posts ” and then in right hand panel click on SQL above in tabs.

STEP 2 :-

Run this query in that SQL

UPDATE wp_posts SET post_content = replace(post_content,'http://oldblog.com','http://newblog.com');

change oldblog.com with your old domain name and newblog.com with your new domain name.

If you want to change URL in particular post only then run this command

UPDATE wp_posts SET post_content = replace(post_content,'http://oldblog.com','http://newblog.com') WHERE ID = 'write post id here';

change oldblog.com with your old domain name and newblog.com with your new domain name.

change ‘ write post id here ‘ with the exact post id where u want to change URL.

wordpress post content url change

That’s it.

8 thoughts on “How to change old attachment url to new url in wordpress post

Leave a Reply

Your email address will not be published. Required fields are marked *

31  +    =  39