How to Bulk Edit Internal Links in WordPress (Safely)

Change many internal links at once with Better Search Replace or WP-CLI: back up, dry run, replace, then crawl to confirm nothing broke.
To bulk edit internal links in WordPress, back up your database, then use a search-and-replace tool to change the old URL to the new one everywhere it appears.
The Better Search Replace plugin does this from the dashboard, and WP-CLI's search-replace command does it from the command line. Always run a dry run first, then crawl the site to confirm every link works.
Bulk edits are useful after changing a URL, moving to HTTPS, merging posts, or switching domains.
Key takeaways
- Better Search Replace adds a page under Tools and includes a dry run that shows how many fields would change.
- The plugin's own FAQ warns that a wrong search or replace string can damage your database, so back up first.
- WP-CLI's wp search-replace supports --dry-run and can be limited to specific tables such as wp_posts.
- Hostinger notes three methods: a plugin, WP-CLI over SSH, or a MySQL query.
- After a bulk edit, crawl the site to find any broken or redirected internal links.
When to bulk edit internal links
Common reasons include:
- You changed a post's URL slug and want links to point to the new URL, not a redirect.
- You moved from HTTP to HTTPS or changed domain.
- You merged several posts into one.
- You want to update anchor text or retarget links across many posts.
Updating links directly is cleaner than relying on redirects. Read do redirected links pass link equity for why.
Plan the changes first
A simple mapping sheet prevents mistakes.
List every old URL in one column and its new URL in the next. Add a third column for the redirect status, so you know which old URLs already send visitors to the right place. Work through the sheet one row at a time, running a dry run for each replacement.
If you are also restructuring content, decide where new links should go before you start. Our guide on how to build internal links covers choosing link targets.
Methods compared
| Method | Best for | Skill needed | Dry run | Risk |
|---|---|---|---|---|
| Better Search Replace plugin | Most site owners | Low | Yes | Medium if strings are wrong |
| WP-CLI search-replace | Developers with SSH | Medium | Yes | Medium |
| MySQL query | Precise, targeted changes | High | No built-in | High |
| Manual editing | A handful of posts | Low | Not needed | Low |
Step 1: Back up the database
Never skip this.
Better Search Replace's plugin FAQ says plainly that entering a wrong search or replace string could damage your database, and advises a backup first.
Use your host's backup tool or a backup plugin, and confirm you know how to restore.
Step 2: Decide exactly what to replace
Be precise to avoid collateral changes.
Search for the full old URL, including the protocol and trailing slash, for example https://example.com/old-post/. Replace it with the full new URL.
Avoid short strings like old-post on their own; they may match other text, image names, or data.
Step 3: Run a dry run
See the impact before saving anything.
With Better Search Replace
Once activated, the plugin adds a page under the Tools menu, according to its plugin page. Select the tables, usually wp_posts and wp_postmeta for content, tick "Run as dry run", and review the count of changes.
A GitHub copy of the plugin readme describes the dry run as a way to see how many fields will be updated.
With WP-CLI
WordPress's developer documentation shows the command and its --dry-run flag, which runs the operation and shows a report without saving changes. You can list tables to restrict the replacement.
wp search-replace 'https://example.com/old-post/' 'https://example.com/new-post/' wp_posts wp_postmeta --dry-run
Step 4: Run the replacement
Run it for real once the dry run looks right.
In Better Search Replace, untick the dry run and run again. With WP-CLI, run the same command without --dry-run.
Hostinger's search and replace tutorial warns that running the plugin without the dry run option changes your database immediately.
The WP-CLI docs also show an --export option that writes the result to an SQL file instead of changing the live database, useful for testing.
Step 5: Clear caches and verify
Check that links work and point where you expect.
- Clear your caching plugin, server cache, and CDN.
- Make sure each old URL has a 301 redirect for visitors and external links; see what is a 301 redirect for SEO.
- Crawl the site and check for 404s and redirected internal links.
- Spot-check several edited posts in the editor and front end.
Merging posts can leave some pages with no inbound links; fix those with how to fix orphan pages.
For finding remaining issues, Yoast's text link counter shows internal links to and from each post, and a crawler shows any that broke.
Bulk editing anchor text
Search-replace can change anchors too, but carefully.
You can replace a full HTML pattern, such as >old anchor</a> with >new anchor</a>, but test it with a dry run. Varied, descriptive anchors are better than one repeated phrase; see does internal anchor text matter.
Using a MySQL query
Only if you are comfortable with SQL.
Hostinger's guide shows an UPDATE query with the REPLACE function to change text in a chosen table and field. It gives the most control but no dry run, so test on a staging copy first.
Common mistakes
- No backup. One typo can affect thousands of rows.
- Replacing too-short strings. They match unintended content.
- Changing the guid column. The WP-CLI examples skip the guid column when changing domains.
- Forgetting serialized data. Use tools that handle it rather than raw SQL for options and widgets.
- Not clearing caches. Old links appear to persist.
After big URL changes, read how to keep link equity when changing URLs.
Frequently Asked Questions
What is the safest way to bulk edit links in WordPress?
Back up the database, use Better Search Replace or WP-CLI with a dry run, check the count, then run the change and crawl the site.
Does Better Search Replace work on multisite?
Yes. Its plugin page explains network administrators can search and replace across all tables from the primary site, while subsite admins are limited to their own tables.
Will bulk editing links break my site?
It can if the search string is wrong. A backup and a dry run reduce the risk significantly.
Should I update links or use redirects after changing a URL?
Do both: add a 301 redirect for outside links and bookmarks, and update your own internal links to point straight to the new URL.
Can I bulk edit anchor text in WordPress?
Yes, with search-replace on the HTML pattern, but test carefully with a dry run, since anchor text appears in many contexts.
Sources
The BacklinkPrice Team researches backlink prices, publisher sites and link building tools. We check prices and plans against each provider's own pages and date them, so you know how current the numbers are.
More from BacklinkPrice TeamRelated guides





