Back to blog
6 min read Tutorials

Find and Replace Text in ACF Fields in Bulk (Including Repeaters)

Find-and-replace plugins for WordPress usually search post titles and content. Text stored in ACF fields is easy to miss: a subtitle field, the rows of a repeater, the text blocks of a flexible content field. When a place, product or company name changes, those copies stay behind. Import Export by RockStarLab PRO can replace text inside ACF fields in bulk with its Content Updater: you pick the posts and the ACF fields, give them a small replace function, and the update runs over every selected post, including repeater and flexible content rows.

PRO: Content Updater and Custom Functions are part of the PRO plugin. We tested with Import Export by RockStarLab PRO 2.1.32 and ACF on WordPress 7.1.

The Example

Three travel guides mention a café that changed its name from “Old Mill Café” to “Mill House Café”. The name appears in three different ACF fields:

Post ACF field Text
Harbour walking guide Guide subtitle (text) Easy waterfront route, ending at the Old Mill Café
Harbour walking guide Itinerary stops (repeater), Stop title Old Mill Café
Woodland walking guide Itinerary stops (repeater), Stop title Old Mill Café terrace
Riverside Weekend Guide Itinerary stops (repeater), Stop title Coffee at the Old Mill Café
Riverside Weekend Guide Guide sections (flexible content), Body …and finish with coffee at the Old Mill Café.

Step 1: Create a Replace Function

In Import Export by RockStarLab > Custom Functions, click New Function. Name it, and enter one line of PHP:

return str_replace( 'Old Mill Café', 'Mill House Café', (string) $value );

Type a sample into Test Function and click Test to see the result before saving:

New Function: Rename Old Mill Café with str_replace code; test input Coffee at the Old Mill Café, output Coffee at the Mill House Café
A one-line replace function, tested before saving.

str_replace is case-sensitive. For a case-insensitive replacement use str_ireplace. You can replace several names at once by passing arrays: str_replace( [ 'Old A', 'Old B' ], [ 'New A', 'New B' ], (string) $value ).

Step 2: Choose the Posts

Open Content Updater, choose Blog Posts, and on the Filters step narrow the posts down. All three guides have itinerary stops, so we filtered by Custom Field (Meta) guide_stops Is Not Empty, which left 3 posts:

Content Updater filters: Custom Field guide_stops Is Not Empty, 3 items to update
Only the posts that have the field.

Without a filter, the update runs over every post of the type. Posts whose fields don’t contain the old name stay as they are, but a filter keeps the run short and easy to check.

Step 3: Select the ACF Fields

On the Select Fields step, open the ACF Fields group and drag in the fields that can contain the text. We used Guide subtitle, Itinerary stops and Guide sections. A repeater or flexible content field is selected as a whole: the function sees all its rows.

Step 4: Assign the Function

On the Field Transformations step, click Assign Transformations for each field and add Rename Old Mill Café from the list:

Field Transformations: Guide subtitle, Itinerary stops and Guide sections, each with 1 transformation
The function assigned to three ACF fields.

Then review the summary and click Start Update. The plugin asks you to confirm that you have a database backup.

Update Complete: 3 processed, 3 updated, 0 skipped, 0 errors
Three posts updated.

Result

All five places now read “Mill House Café”: the subtitle, the three repeater rows and the text in the flexible content block. Everything else in those fields stayed as it was, including the photo in the second flexible content block, which still points to the same Media Library image.

Repeater, group and flexible content values reach the function as JSON text, so a replacement finds words in any row and sub-field. Be careful with replacements that could hit JSON structure, such as quotes or field names; replacing words and phrases is safe.

With an AI Agent or WP-CLI

Content Updater is open to AI agents as abilities. Through the WordPress MCP Adapter, WordPress itself gives an agent only read-only abilities for site, user and environment information; the function, the filter and the update come from Import Export by RockStarLab PRO:

With Import Export by RockStarLab, replace "Old Mill Café" with "Mill House Café" in the ACF fields Guide subtitle, Itinerary stops and Guide sections of all posts that contain it. Count the posts first and tell me the number before you update.

The agent creates the replace function with rsl-ie-pro/function-create, counts the matching posts with rsl-ie/export-count, starts rsl-ie-pro/update-start with the fields, the filter and the function, and follows it with rsl-ie-pro/update-status. Only the fields named in the request are touched. From WP-CLI the same two calls are:

wp rsl-ie ability rsl-ie-pro/function-create '{"name":"Milder to Gentler","code":"return str_replace( \'Milder\', \'Gentler\', (string) $value );"}' --user=admin
wp rsl-ie ability rsl-ie-pro/update-start '{"content_type":"post","fields":["acf_tasting_notes"],"filters":[{"field":"acf_tasting_notes","condition":"contains","value":"Milder"}],"field_functions":{"acf_tasting_notes":[1]}}' --user=admin

We ran them on a test site with Import Export by RockStarLab 2.2.63 and PRO 2.1.56 and an ACF text field: the count found 2 posts, and update job 51 changed “Milder” to “Gentler” in both, with 0 skipped and 0 errors.

Tips

  • Back up first and, for a large site, try the update on a filtered handful of posts before running it on all of them.
  • Post content too: add Title or Content to the selected fields if the old name also appears there; the same function works on them.
  • Other post types: choose Pages, Custom Post Types, Taxonomy Terms or WooCommerce Products in step 1 to replace text in their ACF fields.
  • Keep the function: it stays in Custom Functions, so you can reuse it in imports and exports too.

FAQ

How do I find and replace text in ACF fields in bulk?

With Import Export by RockStarLab PRO: create a Custom Function with str_replace, open Content Updater, choose the posts and the ACF fields, assign the function to each field and start the update.

Does it work in ACF repeater and flexible content fields?

Yes. The function receives the whole field with all its rows and sub-fields, so the replacement reaches every row. In our test, three repeater rows and a flexible content text block were updated.

No, as long as the replacement only matches words. Image sub-fields kept their Media Library images in our test.

Can I preview the result first?

Test the function on sample text in the function editor, and run the update on a small filtered set of posts first. Keep a database backup in case you need to undo it.

Get the free plugin on WordPress.org. Content Updater is part of PRO.

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