Sometimes, you need to replace a text or string on all your WordPress post. For example, you need to change a URL on your post to another text. You don’t know which posts you have added that text to, but you do know that there are a lot of them. That’s going to take a time if you change it manually.

In this post, I will show you how to change or replace a text on all your WordPress posts using online command. Of course, it will always a risk on the progress. If you made a mistake, then you will not be able to undo it. Once you replace the text, it is gone. You will need to carefully type the text you are looking for and the text you want to replace it with. Therefore, I suggest you to take a backup of your WordPress database.

Getting Started

As I mentioned before, we will change or replace the text through WordPress database, therefore, you need to login to your database and the run the command below.

update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'Text to find','text to replace with');

For example, if you wanted to search for text in a WordPress post’s content, then you would write your query like the command below:

update wp_posts set post_content = replace(post_content, 'Text to find','text to replace with');

After you run the command above, you can now visit your WordPress site to see the changes you made.

We hope this article helped you learn on how to replace a text on all your WordPress posts with one click in your WordPress database. If you liked this article, then please share for the others. You can also find us on Twitter and Facebook.