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 performance 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

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 three different recommended options.

1. Better Search Replace Plugin

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

wordpress better search 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 200,000+ active installs with a 4.6 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. Another good alternative premium plugin

Another good alternative premium plugin is the Better Search and Replace Pro plugin from the team over at Delicious Brains.

2. 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

Important! 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 their 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 recommend 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.

Related Articles


Haven't Found What You Need?

Head back to the knowledge base or open a support ticket

Back To The Knowledge Base Open A Support Ticket
email newsletter

Use WordPress?

Join 15,000+ others who get our FREE weekly newsletter with WordPress tips on how to drive more traffic and revenue to your business!

You have Successfully Subscribed!

Send this to a friend