Code

How to do Bulk Replacement of WordPress SQL Database

Imagine that you have many similar typo errors in 100′s of your post such as ”[email protected]” text. The text is very important that you have to correct it with “[email protected]”.  Are you going to edit all your 100′s post one by one?

Trust me, it won’t be fun. Fortunately, there is an easy way to do bulk data replacement in WordPress SQL database. Some people call it “Search & Replace” method.

Remember to backup your database prior doing this.

To do this simple log in to PHPMyAdmin. Select the correct database & click on SQL tab. Use the following code to do the bulk replacement.

UPDATE wp_posts SET post_content = REPLACE (
post_content,
"TEXT TO REPLACE",
"REPLACEMENT TEXT");

Change “TEXT TO REPLACE” with your old text to be replaced & “REPLACEMENT TEXT” with your new text. Remember to leave the open & close quote.