Back to blog
8 min read Content Updater

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

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.

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

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

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

Get the free plugin on WordPress.org.

Dmitriy
About author

Dmitriy

WordPress Developer with 15+ years of commercial experience. Elite Author on ThemeForest and creator of custom WordPress plugins. Passionate about clean code, performance optimization, and building useful tools for the WordPress community.

JOIN THE CONVERSATION

Comments 0

Have a question or a tip to share? Leave it below.

Leave a comment

Your email address will not be published. Required fields are marked *

We store your name, email and comment to show and moderate it; your email is never published. Spam protection is provided by Cloudflare Turnstile and profile pictures by Gravatar. See our Privacy Policy.


Try the plugin with no risks!

New users get 1 month with access to all premium features. Experience the most powerful WordPress data engine today.

Download Now
Get PRO for FREE