Depending on your circumstances, sometimes you need to update things in bulk on your WordPress website. Perhaps you just migrated from HTTP to HTTPS and you need to update all your hard-coded HTTP URLs in the database. Or perhaps you are changing domains and need to update all the database references. There are many scenarios in which knowing how to perform a bulk WordPress search and replace can come in very handy. It can also save you a lot of time, sometimes even hundreds of hours!

WordPress Search and Replace

There are are a lot of different ways in which you can perform a WordPress search and replace. In this post, we will walk you through four different recommended options.

    1. Kinsta Search and Replace Tool
    2. Better Search Replace Plugin
    3. interconnect/it Search Replace DB PHP Script
    4. WP-CLI

1. Kinsta Search and Replace Tool

If you are a Kinsta client, you can use our search and replace tool that is available from right within the MyKinsta dashboard. Follow the steps below.

Step 1

Under “Sites”, click on the name of the site you want to run the search and replace on.

Select your WordPress site in the MyKinsta dashboard

Select your site in MyKinsta

Step 2

Click on Tools, and navigate to the “Search and Replace” tool.

Kinsta's search and replace feature

The search and replace feature

Step 3

There are a number of different operations you can use this tool for, such as:

In this example, we are going to show you how to update HTTP URLs to HTTPS.

Ensure you don’t include any leading/trailing whitespace in either of the fields as this might produce undesirable results.

  1. In the search field, enter the value you want to search for in the database. In this case, we will use our HTTP domain:
  2. Click the “Search” button to run a search on the database. The search and replace tool will show the number of occurrences for the given string.
  3. Check the “Replace” box to continue with the replacement process. In the replace with field, enter the value that should be used to replace the value you are searching for. In this case, we will use our HTTPS domain:
  4. We recommend leaving the “Clear cache when ready” box checked to automatically purge Kinsta Cache after the search and replace process.
  5. Click the “Replace” button.
HTTP to HTTPS search and replace with Kinsta's search and replace tool

HTTP to HTTPS search and replace

Step 4

After the search and replace is complete, you’ll see a confirmation dialog showing the number of replacements processed. In our case, there were seven replacements for to

Search and replace results

Search and replace results

Finally, click “Cancel” to exit the search and replace tool.

2. Better Search Replace Plugin

One of the first methods is to use a free plugin called Better Search Replace.

Better search WordPress replace

Better Search Replace plugin

The Better Search Replace plugin is developed by the awesome WordPress team over at Delicious Brains and is inspired by the interconnect/IT PHP script in option 2 below. These guys know a thing or two about WordPress development. As of writing this, the plugin currently has 300,000+ active installs with a 4.5 rating. It is also actively maintained. You can download it from the WordPress repository or by searching for it within your WordPress dashboard under “Add New” plugins. Some of the features include:

  • Serialization support for all tables
  • The ability to select specific tables
  • The ability to run a “dry run” to see how many fields will be updated
  • No server requirements aside from a running installation of WordPress
  • WordPress Multi-site support

There are hundreds of different use case scenarios. As you can see you in our example below, in the Better Search Replace options, we could easily search for any hard-coded HTTP references and update with the HTTPS version.

better search replace options

Better Search Replace options

There is also a pro version of the plugin available which gives you even more features. You can check out their official documentation on how to better use the plugin.

3. interconnect/it Search Replace DB PHP Script

A second option you have for running a WordPress search and replace is to use a free PHP script from interconnect/it called Search Replace DB.

interconnect search replace

Interconnect search replace

Using this script could break your WordPress website if you don’t know what you are doing. If you are not comfortable doing this, please check with a developer or your web host first.

This script has been around since 2011 and the developers actively update it. Interconnect/it is known for its great WordPress consulting work and development. To use the script, simply download the zip file, extract the folder called search-replace-db-master, and rename it to something secret of your choosing. In our example, we renamed it to update-db-1551. Then upload it via FTP, SFTP, or SCP to your web server’s public directory. This is typically the same directory that contains your /wp-content folder. Then navigate to your secret folder in your browser, such as

interconnect search replace script

Upload Interconnect search replace script

The script will automatically attempt to find and populate the database field but you must check that the details are correct and that it is for the database you wish to carry out a search/replace operation on. You can click on “dry run” first to see what it will be updating/replacing. Then when you are ready click on “live run” which will perform the database updates and the WordPress search and replace.

search replace options

Run search replace on WordPress database

It is also very important due to security reasons that you delete this script after you are done! You can click the “delete me” button. It you don’t, it could leave your website open to attacks. It is also recommended to double check on your web server and confirm that the folder/script has been completely removed.


And finally, the last recommend method for performing a WordPress search and replace is to do it directly with WP-CLI. This is for you WordPress developers out there. For our Google Cloud customers, we provide SSH access so you can use WP-CLI. If you are unfamiliar with WP-CLI you can check out our in-depth post on managing WordPress from the terminal.

Here is an example of the command:

wp search-replace '' '' --precise --recurse-objects --all-tables

You can read more about the parameters available to you for the wp search-replace command in the official WP-CLI documentation, or check out this advanced search and replace WP-CLI guide.

And a fourth option, of course, would be to manually run the search and replace queries directly in MySQL. But this should only be done by professional WordPress developers.

If you enjoyed this tutorial, then you’ll love our support. All Kinsta’s hosting plans include 24/7 support from our veteran WordPress developers and engineers. Chat with the same team that backs our Fortune 500 clients. Check out our plans


Please enter your comment!
Please enter your name here