How to Find and Replace Text in your WordPress Database

There are times when you have a blog that has 400 posts, and you decided to switch your domain and you were using write-in images for your thumbnails in the custom field. Now you have a huge problem because you need to go and replace each image URL to the new URL. Or lets say you wrote 50 posts and you spelled something wrong.  In this post we will show you how you can use an SQL Query for WordPress Database to Find and Replace text in wordpress database.

You need to go to your phpMyAdmin and select your database. Then click the button SQL. Once you have done that paste the following code:

update TABLE_NAME set FIELD_NAME =
replace(FIELD_NAME,'TEXT TO FIND','TEXT TO REPLACE')

This will work with any MySQL Database not just WordPress. Make sure that you make a backup of your database before you run this query.

In the example, we will be replacing the text WordPress to WordPress in our posts

update wp_posts set post_content =
replace(post_content,'Wordpress','WordPress')

Hit Done, and all will be replaced with one click. This is very helpful, and it can save you a lot of time.

Just please make sure to make a Backup of your Database.

Please follow and like us:



Leave a Comment

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