Whether you’ve moved your site and need to update your internal links, or if you’ve made some other change that affects text strings in many places across your website, doing sitewide search and replace can save an enormous amount of time compared to changing each instance manually.
As sites get more established, it can become a pretty fundamental housekeeping chore. Sites gets moved from HTTP to HTTPS; posts gets reorganized; links get broken. For all of those tasks, a search and replace plugin or script can come in very handy indeed. It’s something I find myself using on a nearly daily basis.
Here’s a rundown of some of the better options for search and replace across a Wordpress site, whether it’s a simple single site or a more complicated multisite network. Each has its advantages.
All of these should be used with a great deal of caution, because you really can royally mess up your site–and perhaps knock it offline–if you’re not careful. Always, always, make a backup of your database first and be prepared to restore the backup if something goes pear shaped. Some of these plugins include a function to create a backup copy of your database.
Better Search and Replace
I like this one as a simple and safe option. It’s developed by Delicious Brains, who also make a fantastic site migration plugin that has become my go-to tool for that chore.
Something I particularly like about this one is that when using in a multisite setup, if you access it through an individual subsite, you can only search and replace through that subsite. I often find that I only want to update links or correct text in a single subsite. The way this works greatly reduces the risk of causing issues with other subsites. That said, there is a simple way to search and replace across the whole network if that’s what you want to do–just access it through the root site of the network. (On multisite, it can only be activated at the network level, but you can then access the search and replace functions under each subsite (Tools > Better Search and Replace).)
I also find it works well with large databases without timing out.
The standard version is free and can be downloaded from the Wordpress plugin repository. There’s also a paid Pro upgrade that adds some extra features, but in many instances the free version will meet your needs.
Search and Replace
One of the oldest and most reliable of the search and replace plugins, this one, simply called Search and Replace, works well. For a while, I found that Better Search and Replace offered improved features and functionality, but improvements have since been made to this one to the point that there’s really not much to choose between them anymore.
One thing I like about this one is that it lists each change explicitly. That is available in a paid Pro upgrade to Better Search Replace but isn’t in the free Better Search and Replace plugin. But it’s included in the regular Search and Replace plugin here.
If you find that your search and replace function is timing out–something I used to run into frequently with this plugin–try Better Search and Replace above.
The Search and Replace plugin is free and you can download it from the Wordpress plugin repository.
One thing this offers that not all of search and replace plugins for Wordpress offer is regex part. If you’re new to regular expressions, or regex, it’s an incredibly powerful way to find and manipulate data. It can also create a mess if you get a single character out of place, so dipping your toe in with your Wordpress database isn’t the ideal place to start. You can find more about it here.
So this plugin doesn’t just do direct string replacement–you can also have it match patterns with regular expressions.
It’s free, and you can download it here.
The Scan and Replace Script
Search Replace DB isn’t a plugin, as such. It actually runs separately from your Wordpress site as a PHP script.
And that’s where it’s real power lies–it can work agnostically and directly with the database, not from within the CMS running on that database.
That gives it a lot of power. That’s both good and (potentially) bad. It means that pretty much any search and replace task you have in mind can be accomplished. But it also means that you can royally screw up your database if the syntax isn’t just perfect.
Do remember to delete the files and folder when you’ve finished, because leaving it live is an invitation for anyone out there to interact directly with your database.
It’s free. You can download it here.
Edit the Database Directly
It is, of course, entirely possible to edit the database directly and that can give you maximum control and flexibility. If you’re comfortable doing that, great, in which case you’re probably not reading this in the first place. If you’re not comfortable doing it, it’s probably best to use one of the methods above.
Live Find and Replace
This plugin, Real-Time Find and Replace, is different to the others here. All of the others are for searching and replacing information in the Wordpress database. This one acts as a filter of your public-facing site, between the database and the reader. From that position, it can replace text on the fly before it’s displayed to the user but without actually modifying the database information.
There are a number of different ways this might be useful, but one that’s particularly relevant to the kinds of problem-solving that these other search and replace plugins are aiming at is that it can be used as a safe interim step in case you need something changed quickly but aren’t ready to mess with the underlying database. Or maybe if you want to test variations. You can replace straight text strings or with regex and it doesn’t mess with the database so is easily reversible or correctible.
It’s an interesting option that does things a bit differently. There’s a free version with the basic functionality and paid pro version with extended features. You can find the free version in the Wordpress repository.