How to update urls in a wordpress post via php myadmin

For beginner/ moderate wordpress administrator/site ownersfix wordpress broken image link

I have recently migrated a wordpress website and come across some issues with broken links.

I move images in one folder to a deeper link in my site using ftp.


Old image path:

New image path:

If you have hundreds or thousands of post in your site, it will take heaps of time to open each wordpress page/post, edit the link and save them one by one. Therefor the simple solution is to run a script in back end to update sql database via php myadmin. Normally your word press posts are stored in ‘wp_post‘ table under ‘post_content‘ field (This wp_ prefix can be different from wp installation to installation). The main problem here is to update live database with a script to only affect a certain chunk of data in it. How to update urls or content in a wordpress posts or pages as a bulk using mysql database script? here is the solution…

UPDATE wp_posts SET post_content = REPLACE (post_content, “”, “”);

In the above example is my old URL and is my new url. ans the script will will replace all occurrences of content in first quotations by the content in second quotations, site wide.

you can use the dame script to update any text withing the pages/post.

example: UPDATE wp_posts SET post_content = REPLACE (post_content, “I am happy”, “i am sad”);

Anyway never forget to make a backup before manipulating any database 😉


Leave a Reply

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