How To Run A Site-Wide Search & Replace On Wordpress
Need to find and replace something across every post, page, and option in your WordPress site? It’s safer than it sounds… as long as you use the right tool and avoid the one critical pitfall most people don’t know about.

There comes a time in almost every WordPress site’s life when you need to find one thing and replace it with another. Across hundreds or thousands of posts, pages, options, and meta fields. All at once.
Common scenarios:
- You changed your domain (
oldsite.com→newsite.com) and need to update every internal link - You rebranded and need to swap a product name or your business name everywhere
- You moved your images to a different folder or CDN and need to fix the URLs
- You’re migrating from one tool to another and need to swap embed codes or tracking pixels
- A plugin you used to use left shortcodes everywhere that you now need to remove
Whatever the reason, the manual approach (editing every post by hand) is a non-starter for any site that’s been around for more than a few months. You need a real tool.
The good news: there are several solid ways to do this, and each one is reliable as long as you understand one critical pitfall first. Let’s get into it.
The Serialized Data Trap (Read This Before Anything Else)
Before you run any search-and-replace operation on a WordPress site, you need to understand this:
WordPress stores some data in a format called PHP serialized arrays. This is a structured format that includes character counts as part of the data itself. It looks something like this:
a:2:{s:5:"hello";s:5:"world";}
That s:5 means “the next string is 5 characters long.” If you do a raw search-and-replace that changes the length of any value inside a serialized array… say, replacing “hello” with “goodbye”… the character count is now wrong, the serialized data is broken, and any plugin or feature relying on that data will silently fail or throw errors.
This is why you cannot just run a raw SQL UPDATE query on the database to do search-and-replace. It will corrupt your serialized data and you’ll have a really bad day.
The tools below all handle serialized data correctly. They unserialize the data first, do the replacement, and re-serialize it with the correct character counts. That’s why you use a tool built for this job rather than rolling your own.
Always back up your database before running search-and-replace. Always. Doesn’t matter how confident you are. Doesn’t matter how simple the change is. Back it up. If something goes wrong, you’ll be glad you did.
Method 1: The Plugin (Easiest, No Command Line Required)
The de facto standard plugin for this in 2026 is Better Search Replace by WP Engine (formerly by Delicious Brains). It’s free, well-maintained, and handles serialized data correctly.
Steps:
- Install and activate Better Search Replace from the WordPress plugin repository
- Go to Tools → Better Search Replace
- In the “Search for” field, enter the exact text you want to find
- In the “Replace with” field, enter what you want to replace it with
- Select which database tables to run the operation on. For most cases, you want to select all tables. (Holding Ctrl/Cmd and clicking lets you multi-select.)
- Critical first step: check “Run as dry run?” This shows you how many changes would be made without actually making them. Always do a dry run first.
- Review the dry run results. If the count makes sense and matches your expectations, uncheck “Run as dry run?” and click “Run Search/Replace”
- The plugin processes the change and shows you a count of fields modified
A few important notes:
- Be precise with your search string. The tool replaces every occurrence, exactly as written. If you search for
davidand replace withdave, you’ll also catchdavidson,davidsonville, etc. The more specific your search string, the safer the operation. - For domain changes, use the full URL with protocol. Search for
https://oldsite.comrather than justoldsite.com. This avoids accidentally catching the domain in places where it shouldn’t be replaced (like in a quote or reference). - Deactivate the plugin when you’re done. It doesn’t need to be sitting around active when you’re not using it.
Method 2: WP-CLI (Faster, More Powerful, For The Technical)
If you’re comfortable with the command line and have SSH access to your server, WP-CLI is the fastest and most flexible option. It has a built-in search-replace command that’s been battle-tested across millions of WordPress sites.
The command looks like this:
wp search-replace 'oldstring' 'newstring' --dry-run
The --dry-run flag shows you what would change without actually changing anything. This is the equivalent of the dry-run feature in the plugin… and just like with the plugin, you should always run it first.
When you’re confident the change is correct, drop the --dry-run:
wp search-replace 'oldstring' 'newstring'
WP-CLI handles serialized data correctly out of the box. It’s also significantly faster than the plugin approach because it processes data directly without going through WordPress’s full plugin/admin loading.
A few useful flags:
--all-tables— search through every table, not just core WordPress tables. Useful if you have plugins that store data in their own tables.--precise— uses PHP’s serialization handling (more accurate but slower)--export=output.sql— instead of modifying the database, output the SQL that would do the replacement to a file. Useful if you want a manual review before applying.
Method 3: Let An AI Tool Do It For You
Here’s where things get interesting in 2026.
If you have SSH access to your server (more on that in a moment), you can connect an AI coding tool like Claude Code (or OpenAI’s Codex) directly to your hosting environment. Once that connection is set up, you can essentially talk to your AI assistant in plain English and have it perform the search-and-replace for you.
A typical interaction looks like this:
“I need to change every reference to oldcompany.com to newcompany.com on my site. Run a dry-run first using WP-CLI, show me how many fields would be affected, and if it looks right, run it for real.”
The AI handles the WP-CLI command itself, runs the dry-run, reports back to you, and executes the change after you confirm. What might take a non-technical user an hour of figuring out… or just feel impossible because the command line is intimidating… happens in about 30 seconds.
This is exactly what I do for Concierge clients all the time. I have AI assistants baked into the Concierge Cloud setup so that operations like this happen fast and cleanly. Tasks that would take a client hours of nerdy work, with all the associated risk of getting it wrong, get handled in minutes.
If you want to set this up yourself:
- Talk to your web host about SSH access. Not all hosting plans include it, and the setup varies. Most managed WordPress hosts (Kinsta, WP Engine, Cloudways, anything with a real backend) offer SSH on at least their mid-tier plans. Cheap shared hosting usually doesn’t.
- Install Claude Code (or your AI tool of choice). Claude Code can connect to remote servers via SSH and run commands on your behalf, with you reviewing each step.
- Confirm WP-CLI is available on your server. Most modern WordPress hosts have it pre-installed.
- Always, always, always have a fresh backup. This is the most important point of this whole section. AI tools are powerful, but they can occasionally misinterpret what you asked for or run a command that has unintended effects. I’ve personally never had Claude Code mess up a search-and-replace operation, but it absolutely can happen. Backups are your safety net.
The combination of SSH access, WP-CLI, and an AI assistant is essentially what makes a managed service like Concierge run efficiently. The same setup is available to you if you’re willing to put it together. It’s not as hard as it sounds, and once it’s set up, the leverage is enormous.
When To Use Which
Use the plugin if:
- You don’t have SSH access to your server
- You’re not comfortable with the command line or AI tools
- You’re doing a one-off change and don’t need to script anything
Use WP-CLI directly if:
- You have SSH access (most managed WordPress hosts provide it)
- You’re comfortable with terminal commands
- You’re doing a domain migration or other large operation where speed matters
Use AI + SSH if:
- You have SSH access but don’t want to memorize WP-CLI syntax
- You’d rather describe what you need in plain English and have the AI handle the technical details
- You’re regularly doing operations like this and want maximum leverage
Common Gotchas
A few things people regularly trip over:
Caching gets in the way. After running a search-and-replace, your site’s cache plugin and any CDN you’re using are still serving the old content. Always clear all caches after the operation: WordPress cache plugins, server-level caches (LiteSpeed, Nginx, etc.), and any CDN like Cloudflare.
Some plugins store data in their own tables. If you have a plugin like WooCommerce, FluentCRM, or LearnDash, those plugins create their own database tables. Make sure your search-and-replace covers them too. With Better Search Replace, select all tables. With WP-CLI, use --all-tables.
Object caches can hide changes. If your host uses Redis or Memcached for object caching, the old values can stay cached even after you’ve updated the database. Flush the object cache after your search-and-replace.
Domain changes need more than just search-and-replace. When you change domains, you also need to update the siteurl and home options (which Better Search Replace and WP-CLI both handle if you replace the URL string), update permalinks, set up 301 redirects from the old domain, and update any references in your wp-config.php or hard-coded files. A search-and-replace handles the database side, but it’s not the entire migration.
Putting It Into Practice
Site-wide search-and-replace on WordPress is one of those tasks that sounds intimidating but is actually pretty safe… as long as you use the right tool, do a dry run first, and back up your database before pulling the trigger.
For most people, the Better Search Replace plugin is the right move. For technically comfortable site owners, WP-CLI’s search-replace is faster and more flexible. And if you’ve got an AI assistant connected to your server, you can have these operations done for you in about as long as it takes to describe what you need.
If you’re looking at a project like a domain change or a major content migration and you’d rather not handle it yourself, that’s exactly the kind of work I do for Concierge clients all the time. I’ll handle the search-and-replace, the redirects, the cache flushing, and everything else that goes with making the change clean and complete.

David Risley has been building on the web since 1998 and founded Blog Marketing Academy in 2008. After years helping bloggers and online entrepreneurs grow their businesses, he now runs Concierge — a done-for-you WordPress management service for membership sites and online businesses. He manages hosting infrastructure, handles the technical heavy lifting, and keeps client sites running at peak performance. Click to read his full origin story.
Popular Right Now

What If Your Website Was Just… Handled?
I manage WordPress sites for creators and small teams who don’t want to fight tech anymore. Hosting, updates, security, performance — plus a real human you can ask anything.



