Find and replace across your posts and pages

MaintenanceBeginner~10 minUpdated

Before you start

A connected site with content reads on and the content write abilities enabled. Know the exact old phrase and the exact new one, both plain visible text. A match inside a tag or attribute such as an href or src is refused, and so is a replacement that adds markup, so those posts are reported as skipped. Pages are reached only while the Update page tool is on. This edits post and page content only.

A brand name changes, a product gets renamed, a URL you reference everywhere finally moves, and now an old phrase is scattered through years of posts and pages. Opening each one to fix it is the definition of tedious, and the search-and-replace plugins that reach into the whole database are the ones people are most nervous about running, because a bad match there can corrupt serialized data you never see.

This stays narrow on purpose. It edits the readable content of posts and pages, shows you every hit first, and does the replacement literally.

The prompt
I need to change [old phrase] to [new phrase] everywhere it appears in my
posts and pages. Start read-only: search the content for [old phrase] and
show me every post and page it turns up in, with the excerpt it returns so I
can see the context. Change nothing yet.
Wait for my go-ahead. Only after I approve, run a literal find-and-replace
of [old phrase] with [new phrase] in each post and page body, in small
batches, showing me each batch before it saves. Edit only the body text,
leave the status alone so nothing republishes, and keep a list of every old
and new string so I can see exactly what changed. This only works on plain visible text: if
the phrase sits inside a tag or attribute such as an href or src, the tool refuses, so list that
post as skipped and leave it for me. When you finish, list every post and page
you changed and every one you skipped.

Why this is safe to run, and exactly how far it reaches

The first pass is a read. The search shows you every post and page the old phrase lives in, with the excerpt it returns, so you approve the real list before anything saves. The replacement is literal, one exact string for another, so it will not fuzzy-match its way into text you meant to keep, and it does not touch the status, so nothing republishes. The old phrase is in the list you approved. Swapping back changes every match of the new phrase, including any that were already there, so check the post first.

Be clear on the scope, because this is where the honest limit sits: this edits the content body of posts and pages only. It does not reach into the database directly, site options, widgets, navigation menus, theme or plugin settings, or values stored as serialized data. If your phrase lives in a widget, a theme option, or a page-builder’s stored layout, this recipe will not find it or change it, and that is by design, since those are exactly the places a blunt database replace does its damage. The same guard applies inside a post: a match that lands in a link, an attribute or other markup is skipped and reported, not edited. The content write ability stays off until you enable it, every call is checked against the bound user’s capability, and each edit is written to the Activity Log with the post or page it changed.

Already connected? Skip the paste. Ask your agent for the “find and replace across your posts and pages” recipe, give it the old and new phrase, and it runs the same search-approve-replace flow on your own install.

How it works

  1. Search your content for the old phrase and show you every post and page it appears in.
  2. Show the excerpt that holds the phrase for context and wait for your approval.
  3. Run a literal find-and-replace of the old phrase for the new one, plain text only, body only.
  4. Report any post where the phrase sits inside a tag or attribute such as an href or src as skipped.
  5. Work in small batches, showing you each batch before it saves.
  6. Return the list of every post and page it changed.

Questions

Does this change my whole database, or just the content?
Just the content. It edits the body of posts and pages and nothing else. It does not touch the database directly, site options, widgets, menus, theme or plugin settings, or anything stored as serialized data, so a phrase living in a widget or a page-builder layout is not in scope.
Can I undo a replacement?
Yes. Each edit swaps one exact string for another and never changes the status, so nothing republishes. The old phrase is in the list you approved. Swapping back changes every match of the new phrase, including any that were already there, so check the post first. Revisions can also be compared if the post was saved before.