How to find and replace text in a WordPress database

Learn how to add custom CSS in WordPress
How To Remove “Proudly Developed With WordPress” From Your Website

Often, you will need to search and replace words or parts of your WordPress site for any of the reasons as:

  • Maybe you’re trying to remove a keyword from your WordPress site. For example, let’s say ” keyword A “, a few months ago, because at that time thought to be a good idea for the SEO of your site. But now, a few months have passed, you notice that need to change the key word for another, it may be better or more appropriate, then say ” keyword B ” is best for your site. Now, if the same keyword is spread by your website, the manual override will have to involve you opening a 100MB database by changing the data and relaying it again. But do not worry, because there are much easier ways to accomplish this task and we will discuss them below.
  • You may have repeated grammatical or typing errors when creating a website. For example, you may have typed “out of bounds” as wanted to enter “off the court” and now you need to find where they are scattered around the site and replace them.
  • After WordPress update, some strange characters began to appear on your site, and of course you want to remove them.
  • You added a URL or a set of phrases to some of your posts but have no idea where and in what posts they are. For example, you have added the biography of an author at the end of some of your articles and now need to update them.

These are a few scenarios where you may come to need a feature to “search and replace”, but okay if your scenario is a bit different from the mentioned above. No matter what the scenario, look for each file and search manually is a tedious job that anyone would want to do. Fortunately for us, there is a faster and more efficient way to replace things in your WordPress site. One of the biggest disadvantages, however, if you make a mistake during the process of search and replace, you can not reverse the changes. Then consider Create a backup of your WordPress website before proceeding to thus prevent serious data loss.

Table of Contents

  • Option 1: Using a plugin
  • Option 2 : Using Search MySQL
  • Conclusion

Option 1: Using a plugin

The plugins make the life of a WordPress site owner easier every day. If you do not have any experience with website development or do not intend to go through the pain of performing SQL queries, then you can use plugins like going to your WordPress admin panel by navigating to the session Plugins Add New

add a new plugin in wordpress

In the search field, between Better Search Replace and install.

Best plugin to search and replace in wordpress database

Click Enable when finalizing facilities, and the plugin will be ready and implemented. You will find it in the session → Tools Better Search Replace

plugin search and replace in wordpress

Next step, you need to put the information you would like to change:

Best wordpress plugin for search and replace

  • “Search For” must contain the phrase or sequence of characters you want to change.
  • “Replace with” must contain the value you want to replace the used up.
  • “Select Tables” will allow you to choose which tables of your database will be affected. If you want to select all, you can use CTRL + A , or you can select individual tables holding CTRL and clicking them to select them.
  • If you want this action do not count on uppercase or lowercase characters, be sure to check the box.
  • Check the box to ” Run as Simulation?” If you want to review the changes before applying them really.

If you run the plugin without the simulation option, it immediately updates your changes in your database and you will see similar results:

wordpress plugin to search and replace full

Congratulations! You could edit all entries in your WordPress database using a plugin.

Option 2: Using MySQL Query

You can also perform a search operation using phpMyAdmin , which is usually located in the hosting control panel.

phpmyadim in cPanel

If you have many databases on your account, you open the file wp-config.php to find the database name that your site uses.

place name in wordpress database

When you enter phpMyAdmin, select the database that WordPress uses and click the tab SQL .

sql in phpMyAdmin

This is the query syntax that you use to perform the operation:

table_name update September FIELD_NAME = replace (FIELD_NAME, "Text to search, 'text to replace it with');

For example, if you want to update the table of posts, you could accomplish using this research:

wp_posts update September post_content = replace (post_content 'Find this text,' 'Replace it with this');

Note: wp_ should be replaced by the appropriate prefix used by the tables of your WordPress database.

When you have completed the survey, click the “button Go “.

WordPress search and replace in phpmyadmin

After a few minutes of the process, you’ll see exactly how many rows were affected.

sql successfully held

Good job! You learned how to manipulate the information in your WordPress database using SQL queries in phpMyAdmin.

Conclusion

Perform most things in WordPress is really easy, and the search operation and replacement is no different. If you know another way Evolva SQL and do not want to install a plugin to do the job, then the second way is right for you. However, if you want to advance your service and would prefer a plugin do the work for you, then the option is one his way.