Back to blog
4 min read Export Guides

Find Every WordPress Post That Links to a Domain (and Fix the Links in Bulk)

A supplier closes its shop, a partner moves to a new domain, or an affiliate program ends. Somewhere in your posts are links to that site, and WordPress has no list of them. With Import Export by RockStarLab, one export filter lists every post that links to a domain, and importing the same file back with a find-and-replace rule fixes the links in one pass. In the example, a coffee roastery’s links move from its old green-coffee supplier to the new one.

Free: everything in this guide works in the free plugin for posts and pages. PRO: the same for products and custom post types.

Short Answer

  1. In Export, choose Posts and add the filter Content Contains the-domain.com.
  2. Export ID, Title, Permalink and Content to CSV. That’s your list of posts to check.
  3. To change the links, import the same file with Check for Existing Items by Field = ID, If Match Found = Update and a Replace links rule from the old address to the new one.
  4. Repeat for Pages.

Find the posts

Our site had five posts; three of them linked to shop.greenbeans.example. In Export, we chose Posts and added one filter:

Export filter: Content contains greenbeans.example; total items available 3
One filter finds every post whose content mentions the domain.

Use only the domain, without https:// or www, so that every link to it matches: the home page, product pages and links with tracking parameters such as ?utm_source=.

We exported ID, Title, Permalink and Content to CSV. The file listed the three posts:

ID Title Links to the old shop
2037 Where We Buy Green Coffee 2: the home page and /ethiopia-guji
2038 Home Roasting Starter Kit 1: /sample-pack
2039 Cupping Notes: Kenya AA 1: /kenya-aa?utm_source=roastery

The Permalink column gives you a clickable list for checking each post by hand, and the Content column shows every link in context.

When the new address follows the same pattern, you don’t have to edit each post. Import the file you just exported, choose Posts, and click Auto Map. On the options step:

Import options: Check for Existing Items by Field ID, If Match Found Update, If No Match Found Skip, Replace links from https://shop.greenbeans.example to https://www.newbeans.example
Import the same file back by ID, with one find-and-replace rule.
  • Check for Existing Items by Field: ID and If Match Found: Update, so each row updates its own post.
  • If No Match Found: Skip, so nothing new can be created by mistake.
  • Replace links: Replace What https://shop.greenbeans.example, Replace To https://www.newbeans.example.
Import Completed Successfully: 3 successful, 3 updated, 0 created, 0 failed
The three posts were updated; nothing new was created.

All three posts were updated, including both links in the first post and the link with the tracking parameter: https://www.newbeans.example/kenya-aa?utm_source=roastery. The slugs stayed the same. Auto Map sends the Permalink column to Slug, and the import takes the slug from that address.

The rule replaces the address and keeps the link text, so “Green Beans Co” still said “Green Beans Co”. If the name changed too, add a second rule with Add More, from the old name to the new one.

Don’t forget pages

An export of Posts doesn’t include pages. Our “Suppliers” page still linked to the old shop after the import. Run the same export and import with Pages, and with every custom post type that might contain the link.

Before you import

A find-and-replace rule changes every match in the content. Try it on one or two rows first, and back up the site before importing the full file. Keep the exported CSV: it’s a copy of the content before the change.

With an AI agent

An AI agent connected through the WordPress MCP Adapter (see connecting Claude Code to WordPress) can check that nothing is left:

How many posts and pages still contain greenbeans.example?

In our run, the agent called rsl-ie/export-count with a “content contains” filter, once for posts and once for pages. It reported 0 posts and 1 page: the Suppliers page that still needed the same fix.

FAQ

The Content filter searches the post content. For excerpts, use the Excerpt filter. For a custom field, add a Custom Field filter.

Run one export per domain. Several Contains filters in one export must all match, so they find only posts that link to every one of the domains.

Will the import change anything else in the posts?

Only the mapped columns are written, and only text that matches the Replace links rule changes. In our test, titles and slugs stayed the same.

The rule replaces text with other text. To remove links but keep their words, edit the Content column in the CSV and import it back by ID.

They aren’t part of post content. Check Appearance → Menus and your widgets separately.

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