---
title: "Bulk Find and Replace in WordPress Posts (With a Preview First)"
url: "https://wpimportexport.com/bulk-find-replace-wordpress-posts/"
description: "Bulk find and replace text in WordPress posts safely: find the posts, preview the rule on real content, then update. Case, plurals and URLs tested."
type: post
published: 2026-11-08T11:19:44+00:00
modified: 2026-11-14T10:41:12+00:00
categories: ["Content Updater", "Tutorials"]
tags: ["bulk content update WordPress", "content transformation functions", "Content Updater", "Import Export by RockStarLab", "WordPress Bulk Update"]
docs_topics: ["Bulk updates and automation"]
---

# Bulk Find and Replace in WordPress Posts (With a Preview First)

A product gets a new name, a phone number changes, a brand drops a word. Now the old text sits in dozens of posts. WordPress has no find and replace for content, and a database search-replace tool changes everything it finds without showing you the result post by post. The safer way is a preview first: find the posts, test the rule on real content, then update only those posts.

Everything below was run on a test coffee shop with [Import Export by RockStarLab](https://wordpress.org/plugins/import-export-by-rockstarlab/) 2.1.23 and the PRO add-on 2.1.3 on WordPress 7.1. The Content Updater and transformation functions are **PRO** features. Free alternatives are at the end.

## Short Answer

1. **Back up** the site and export the ID and Content of the posts you will change.
2. **Import Export → Functions → New Function**: write the replace rule, for example `return preg_replace( '/\bold name\b/i', 'New Name', $value );`.
3. **Import Export → Content Updater**: Blog Posts, filter **Content Contains** the old text, select the **Content** field.
4. Assign the function and click **Test Pipeline** with a real paragraph from one of the posts.
5. Check the summary and click **Start Update**.

## The Test Case

The shop renamed its “Cold Brew Kit” to “Cold Brew Set”. Three posts mentioned it nine times in different forms:

| Where | Text in the post | Should change? |
| --- | --- | --- |
| Paragraphs, heading, caption, button, link text, image alt | Cold Brew Kit | Yes |
| Start of a sentence, typed in lowercase | the cold brew kit has been our best seller | Yes |
| Plural | Cold Brew Kits ship in a gift box | Yes, to “Cold Brew Sets” |
| Emphasis in capitals | the COLD BREW KIT saves you the straining | Yes |
| Product link | `/product/cold-brew-kit/` | No, the product URL did not change |
| Image file | `cold-brew-kit.jpg` | No, the file keeps its name |

The last two rows matter most. If a replace touches them, the link and the image break.

## Step 1: Back Up and Save the Original Text

The Content Updater writes straight to the posts. In our test it did not create a WordPress revision for the change, even with revisions enabled, so the post’s revision history is not your undo. Make a backup with UpdraftPlus (**Backup Now**) or ask an AI agent to run `rsl-ie/updraftplus-backup-start`. See [How to Create a WordPress Website Backup and Restore It](https://wpimportexport.com/how-to-create-a-wordpress-website-backup-and-restore-it/).

Also export the posts you are about to change with two columns, **ID** and **Content**, using the same filter as in Step 3. If something goes wrong, import that file back with matching by ID and the original text returns. Details: [How to Roll Back a Bad WordPress Import or Sync](https://wpimportexport.com/roll-back-bad-wordpress-import/).

## Step 2: Write the Replace Rule

Go to **Import Export → Functions** and click **New Function**. A function receives the field’s value as `$value` and returns the new value.

![New Function dialog with the name Rename Cold Brew Kit (any case) and PHP code using preg_replace with a case-insensitive pattern](https://wpimportexport.com/wp-content/uploads/2026/11/02-replace-function.webp)

_The replace rule as a reusable function: one line of PHP._

The obvious rule is an exact replace:

```
return str_replace( 'Cold Brew Kit', 'Cold Brew Set', $value );
```

It is case-sensitive. In our posts it changed 7 of the 9 mentions and skipped “the cold brew kit” and “COLD BREW KIT”. The rule we used instead:

```
return preg_replace( '/\bcold brew kit(s?)\b/i', 'Cold Brew Set$1', $value );
```

- `i` at the end ignores letter case.
- `\b` on both sides matches whole words only, so “kitchen” can never become “Setchen”.
- `(s?)` and `$1` keep the plural: “Cold Brew Kits” becomes “Cold Brew Sets”.
- The pattern has spaces, so the hyphenated `cold-brew-kit` in the product URL and the image file name does not match.

Every match becomes “Cold Brew Set” with capitals, including the lowercase one at the start of a sentence and the all-caps one. For a product name that is what you want; for ordinary words, check the preview.

Not comfortable with regular expressions? The **Generate function with AI** button writes the code from a plain description when an OpenAI key is set in Plugin Options. Test it the same way before using it. More examples: [Content Transformation Functions for WordPress Import and Export](https://wpimportexport.com/content-transformation-functions-for-wordpress-import-and-export/).

## Step 3: Find the Posts

Open **Import Export → Content Updater**, choose **Blog Posts**, and on the filter step add **Content**, **Contains**, `cold brew kit`. The match ignores letter case: the counter showed 3, including the post where the name appears only in capitals.

![Content Updater Filter Data step with the filter Content Contains cold brew kit and 3 total items to update](https://wpimportexport.com/wp-content/uploads/2026/11/01-find-posts-content-contains.webp)

_Step one is finding the posts: Content contains "cold brew kit" matched 3 posts, in any letter case._

Without a filter the updater runs on every post. The function would leave posts without the phrase unchanged, but a filter keeps the job small and the summary honest. Add **Status Equals publish** if drafts should stay as they are.

On the next step click **Content** to add it to **Selected Fields**. Excerpt and Title can be added too if the old name appears there.

## Step 4: Preview the Replacement

On **Field Transformations** click **Assign Transformations** next to Content and add your function. Under **Preview Transformation**, paste a real paragraph from one of the posts, with its HTML, and click **Test Pipeline**.

This is where the exact replace showed its gap. “Cold Brew Kits” changed, “the cold brew kit” did not:

![Test Pipeline preview of an exact str_replace: the lowercase cold brew kit stays unchanged while Cold Brew Kits becomes Cold Brew Sets](https://wpimportexport.com/wp-content/uploads/2026/11/03-exact-replace-misses-lowercase.webp)

_The preview catches the problem: an exact replace skips the lowercase mention._

The case-insensitive rule changed both and left the `<p>` tags as they were:

![Test Pipeline preview of the case-insensitive rule: both the lowercase mention and the plural are replaced and the HTML paragraph tags are kept](https://wpimportexport.com/wp-content/uploads/2026/11/04-regex-replace-preview.webp)

_The case-insensitive rule replaces both mentions and leaves the HTML alone._

Test more than one sample: a paragraph with a link, an image block, a heading. If a URL or file name contains the phrase with spaces (rare, but possible in captions or alt text), you will see it here.

Want to see the result for every post before writing? Run an **Export** with the same filter, add Content, click the gear icon on the Content column and assign the same function. The exported file contains the new text for every matching post, and nothing on the site changes. In our dry run the three posts had 9 replacements and the image and product URLs were untouched.

## Step 5: Run the Update

Click **Apply Transformations**, then **Next Step**. The summary shows what will run: 3 posts, 1 field, 1 transformation.

![Content Updater Start Update step: Blog Posts, 3 items, 1 field, 1 transformation, 10 items per iteration](https://wpimportexport.com/wp-content/uploads/2026/11/05-update-summary.webp)

_Last check before writing: 3 posts, 1 field, 1 transformation._

Click **Start Update**. The plugin asks once more to confirm you have a backup.

![Update Complete: 3 processed, 3 successfully updated, 0 skipped, 0 errors](https://wpimportexport.com/wp-content/uploads/2026/11/06-update-complete.webp)

_Three posts updated, no errors._

After the update all nine mentions read “Cold Brew Set”, none of the old name was left, and the image and product links still returned 200. The posts’ “last modified” dates did not change. Open two or three posts on the front end to check the result, and clear your page cache if you use one.

## With an AI Agent (PRO)

An agent connected through the WordPress MCP Adapter can do the same with abilities. We had it rename “Tasting Flight” to “Tasting Trio”:

1. `rsl-ie-pro/function-create` saved the rule `preg_replace( '/\btasting flight(s?)\b/i', 'Tasting Trio$1', $value )`.
2. `rsl-ie/export-count` with the filter `post_content contains "tasting flight"` found 1 post.
3. `rsl-ie/export-preview` with `field_functions: {"post_content": [3]}` returned the post’s new content without saving it: the dry run.
4. `rsl-ie-pro/update-start` with the same fields, filter and function queued the update; `rsl-ie-pro/update-status` reported 1 processed, 1 updated, 0 errors.

Prompts:

```
Find published posts whose content contains "cold brew kit" in any letter case.
Show me how many there are and their titles. Do not change anything.
```

```
Create a transformation that replaces "Cold Brew Kit" with "Cold Brew Set" in any
letter case, keeps plurals, and does not touch hyphenated URLs or file names.
Show me the new content of those posts as a dry run first. After I approve,
make a backup and run the update on the post content only.
```

Keep the approval step: the dry run is the moment to catch a rule that is too broad. More on safe agent edits: [Letting an AI Agent Edit WordPress Content Safely](https://wpimportexport.com/ai-agent-edit-wordpress-content-safely/).

## Content Updater vs a Database Search-Replace Plugin

|  | Content Updater (PRO) | Database search-replace plugins |
| --- | --- | --- |
| Scope | Selected fields of filtered posts, pages, products, terms or users | Whole database tables |
| Preview | Test on sample text; dry run through export shows the result per post | Usually a dry run that counts changes per table |
| Rules | Any PHP transformation: regex, word boundaries, plurals, several steps in a row | Plain text, sometimes case-insensitive |
| Best for | Changing wording in content | Moving a site to a new domain |

For domain and http-to-https changes, a database-wide replace is the right tool. For wording in content, the narrower tool is safer.

## Free Alternatives

- **Edit in a spreadsheet.** Export ID and Content with the free plugin, use your spreadsheet’s find and replace, delete the rows you did not change, and import back by ID with “If No Match Found: Skip”. See [How to Bulk Update Existing WordPress Posts Without Creating Duplicates](https://wpimportexport.com/how-to-bulk-update-existing-wordpress-posts-without-creating-duplicates/). Spreadsheet find and replace is usually case-insensitive and ignores word boundaries, so check the result.
- **Replace links during import.** The free importer has a **Replace links** option for rewriting URLs and other text while a file is imported.

## Common Mistakes

- **Exact replace on mixed-case text.** It silently skips “the cold brew kit”. Use a case-insensitive rule.
- **No word boundaries.** Replacing “kit” alone would also change “kitchen” and “kitten”.
- **Replacing slugs together with names.** A rule for `cold-brew-kit` also rewrites image file names and links that still point to the old URLs.
- **Testing on plain text only.** Paste real HTML from a post into the preview.
- **No undo plan.** The updater does not create revisions. Keep the backup and the ID + Content export.

## FAQ

### Can I replace text in pages, products or custom post types?

Yes. Choose the content type on the first step. The same function works for any text field.

### Can I replace text in the title or excerpt too?

Yes. Select those fields on the Select Fields step and assign the function to each.

### Does it work with page builders?

Block editor content is stored in Content, so it works. Builders that keep their layout in custom fields, such as Elementor, store the text in those fields instead; test on a copy first.

### Is the find case-insensitive?

The **Contains** filter is. The replacement follows your function: `str_replace` is case-sensitive, `str_ireplace` and a regex with `i` are not.

### How do I undo a replace?

Import the ID + Content export you made before the update, matching by ID, or restore the backup.

## Related Guides

- [How to Fix http to https Links in WordPress Post Content in Bulk](https://wpimportexport.com/fix-http-to-https-links-wordpress-content/)
- [Bulk Content Update in WordPress with Content Updater](https://wpimportexport.com/bulk-content-update-in-wordpress-with-content-updater/)
- [Content Transformation Functions for WordPress Import and Export](https://wpimportexport.com/content-transformation-functions-for-wordpress-import-and-export/)
- [How to Bulk Update Yoast SEO Titles and Meta Descriptions from CSV](https://wpimportexport.com/bulk-update-yoast-meta-descriptions-csv/)
- [How to Roll Back a Bad WordPress Import or Sync](https://wpimportexport.com/roll-back-bad-wordpress-import/)

Get the free plugin on [WordPress.org](https://wordpress.org/plugins/import-export-by-rockstarlab/).
