# Shorten every link in your posts

Back up your posts, turn full links to other sites into short links with Scan posts, check the result, and know how to undo it.
Page: https://docs.linkmanagerpro.com/tutorials/shorten-links-in-posts
Use when someone asks: convert links to short links wordpress; mask all links in posts; bulk shorten links wordpress; track outbound links in posts
Intent: How-to

To convert links to short links in WordPress posts you already have (also called masking or cloaking them), run **Scan posts** from the **Scan my site** button on the Dashboard. It checks your published, scheduled and private posts and pages. Each full link to another site becomes a short link on your own domain, like `yoursite.com/link/aB3dE9xQ`. It edits your posts, so back up first. One WP-CLI command puts the original addresses back.

Posts you save from now on don't need a scan: **Mask links when saving posts** (on by default) masks them on every save. How masking treats each kind of link is on [Short links in your posts](https://docs.linkmanagerpro.com/features/link-masking).

## Before you start

- To run **Scan posts**, you need access to Link Manager Pro. Administrators always have it, and editors only when an administrator allows it ([Access for editors](https://docs.linkmanagerpro.com/guides/access)). Posts your account can't edit are left as they were.
- Only administrators can make a backup or change the masking settings. If you're an editor, ask an administrator to do both first.
- Plan to keep the browser tab open while the scan runs. Your browser asks the server to scan the next 20 posts, again and again, until it's done.

## Back up your posts first

A backup with **Posts and pages** ticked holds the content of every post and page. If the result isn't what you wanted, you can put that content back.

Link Manager › Settings › Backup & restore

1. On the **Backup** card, select **Backup**.
2. Under **What to back up**, keep **Posts and pages** ticked.
3. Select **Back up now**.
4. Wait until the button reads **Completed**, keep the file that downloads, then select **Close**.

Before the scan changes a post, Link Manager Pro also saves a revision of it, but only where WordPress keeps revisions. The backup is the copy you can count on ([Backup and restore](https://docs.linkmanagerpro.com/guides/backup-restore)).

## Check your masking settings

The scan follows the same rules as masking on save, and every link it masks keeps what it got at that moment. So settle these before you start.

Link Manager › Settings › General

1. Decide on **Mask internal links**. Off (the default), only links to other sites change. On, full links to your own pages become short links too, under the **Internal link prefix** (`go` by default). The scan uses this switch even while **Mask links when saving posts** is off.
2. Check the **Short link prefix** (`link` by default): every masked link to another site carries it, except links to an affiliate's domain while an **Affiliate link prefix** is set (they carry that one). Change it now if you're going to, because `unlink` restores only links that use your current prefixes ([General settings](https://docs.linkmanagerpro.com/guides/settings/general#short-link-prefix)).
3. Leave **Mask links when saving posts** on if links in posts you save later should be masked too. The scan works either way.
4. If you changed anything, select **Save changes**.

Masking also adds `rel` values to each link, the part of a link's HTML that tells search engines how to treat it ([what a masked link looks like](https://docs.linkmanagerpro.com/features/link-masking#what-a-masked-link-looks-like)). Links to other sites get `nofollow noopener` by default. The values come from your [Redirection settings](https://docs.linkmanagerpro.com/guides/settings/redirection) and your [affiliates](https://docs.linkmanagerpro.com/guides/affiliates), and they're written into the post once, so set them up now.

## Bulk shorten links in your posts with Scan posts

**Scan posts** goes through your posts and pages in order and replaces each full link to another site with a short link, in place. A destination that already has a short link reuses it.

::: warning
**Scan posts** edits your posts: it replaces link addresses in their content. Make the backup above first. There's no undo button in the dialog. The undo is a WP-CLI command or a restore of your backup ([see below](#how-do-you-undo-the-scan)).
:::

Link Manager › Dashboard

1. Select **Scan my site**. The **Scan posts** dialog opens.
2. Read **Posts and pages to check** (1). It counts the posts and pages the scan goes through, with the total next to it. Below, it splits them by status, like `120 published · 2 scheduled · 5 private`.
3. Read **This edits your posts and pages** (2). If you haven't made a backup yet, select **Cancel** and make one.
4. Select **Scan posts**. A bar shows how many posts and pages are done and how many links became short links so far.
5. Keep the tab open until it finishes. To end it early, select **Stop**: posts already scanned keep their changes, and the rest stay as they were.
6. Read the summary, then select **View short links** to open your short links, or **Done**.

[Screenshot: The Scan posts dialog for converting links to short links in WordPress posts, marked: 1 Posts and pages to check with the count by status, 2 the This edits your posts and pages warning]

Leaving the page during a scan asks first, then stops it after the current posts. Setup offers the same dialog as **Scan my posts**, in its **Bring your links** step ([Quick start: setup](https://docs.linkmanagerpro.com/getting-started/quick-start)).

## Which posts and links does the scan leave alone?

The scan changes only full links (`http://` or `https://`) to other sites, in posts and pages that are published, scheduled or private. Links to your own pages change only while **Mask internal links** is on. It leaves alone:

- Drafts and pending posts.
- Other content types, like products or portfolio items from another plugin.
- Links in blocks that keep their address in the block's settings, like the File block. The summary counts them.
- Links that are already short links, relative links like `/about/`, anchors, and `mailto:` or `tel:` links.

The full list, with menus, widgets and comments, is in [which links masking changes](https://docs.linkmanagerpro.com/features/link-masking#which-links-masking-changes-and-which-it-leaves-alone).

## Shorten links with WP-CLI instead

`wp link-manager-pro link` runs the same scan from your server's command line, so no browser tab has to stay open. It checks the same posts as **Scan posts**.

1. Run the dry run. It counts the posts it would check, by status, and doesn't change anything. It doesn't say which links would change.

   ```bash
   wp link-manager-pro link --dry-run
   ```

2. Run the real scan. Its question names how many posts it will check: compare that with the dry run before you answer `y`.

   ::: warning
   `link` edits your posts, like **Scan posts**. Back up first.
   :::

   ```bash
   wp link-manager-pro link
   ```

3. Read the `Success` line, like `Masking complete. Posts updated: 30, links turned into short links: 45 (new short links: 12).` A `Warning` after it counts posts that were skipped or couldn't be saved ([WP-CLI commands](https://docs.linkmanagerpro.com/guides/wp-cli#if-something-goes-wrong)).

You don't need `--user`. Type options carefully: WP-CLI stops `link` with an error when an option is mistyped, such as `--dryrun`, and nothing runs. The real scan asks first unless you add `--yes`. Every option is on [WP-CLI commands](https://docs.linkmanagerpro.com/guides/wp-cli#mask-links-in-your-posts-with-link).

## How do you check that your links became short links?

The scan's summary tells you how many posts it checked and how many links became short links, in how many posts. It also says how many new short links it created. That number can be lower, because a destination that already had a short link reuses it.

The summary can add notes:

- Links left as they were because their block keeps the address in its settings.
- Posts left as they were. A post is left when it changed during the scan or your account can't edit it. It's also left when WordPress would remove some of its content, or when saving it would also change its status or URL slug.
- Posts WordPress couldn't save. Run the scan again to retry them.

Then check a post. Open one on your site and hover over a link to another site: it now starts with your domain and prefix, like `yoursite.com/link/`. **View short links** opens Link Manager › Short Links, newest first, where the new links have random slugs. A short link's report shows **Placed in**, the number of published posts that link to it ([Link report](https://docs.linkmanagerpro.com/guides/link-report)).

## Can you track outbound links in your posts?

Yes, once they're short links. A visit through a short link is counted on your server, so each masked link in a post has its own clicks. Open a link's report and read **Clicks** and **Top posts sending clicks** ([Track clicks on a link](https://docs.linkmanagerpro.com/tutorials/track-link-clicks)). Counting needs **Click tracking** on under Link Manager › Settings › Tracking, which is the default.

## How do you undo the scan?

You undo the scan with the WP-CLI command `wp link-manager-pro unlink`. It puts the original address back in every post where Link Manager Pro masked links, including the posts the scan changed. The `rel` values masking added stay. There's no button for this in the admin.

::: warning
`unlink` edits your posts. Back up first, and read the post count in its question before you answer `y`.
:::

1. Go to Link Manager › Settings › General, turn off **Mask links when saving posts**, then select **Save changes**. While it's on, the next save of a restored post masks it again.
2. Run `wp link-manager-pro unlink --dry-run` and check the counts. It answers like `Success: Posts would change: 30. Links restored: 45, short links kept: 0, unresolved: 0.`
3. Run `wp link-manager-pro unlink`.
4. Turn **Mask links when saving posts** back on if you want posts you save later to be masked again.

What `unlink` doesn't put back:

- The `rel` values masking added, like `nofollow noopener`. Add `--strip-rel` to remove them, but it removes the whole `rel` of each restored link, values you wrote yourself too. While a `sponsored` stays, a post still counts for the [affiliate disclosure](https://docs.linkmanagerpro.com/guides/settings/disclosure).
- Short links you added yourself, for example from the editor. To remove every short link from your posts, say before you delete the plugin, run `wp link-manager-pro unlink --scope=all --restore-shortlinks --dry-run`. If the counts look right, run it again without `--dry-run` ([Uninstall and delete data](https://docs.linkmanagerpro.com/guides/uninstall#remove-short-links-from-your-posts-before-you-uninstall)).
- Links that don't use your current **Short link prefix**, **Internal link prefix** or **Affiliate link prefix**.

The short links stay in your **Short Links** list, with their clicks ([what `unlink` keeps](https://docs.linkmanagerpro.com/guides/wp-cli#restore-original-links-with-unlink)). Like `link`, `unlink` stops with an error when an option is mistyped, and nothing runs. Read its question before you answer `y`. A dry run skips WordPress's save checks, so the real run can still leave some posts as they were.

### Undo with your backup instead

Restoring the backup you made puts back each post's content as it was in the file. It also undoes every edit made to those posts since the backup.

::: warning
The Restore dialog ticks every item except **Posts and pages** to start with. Restoring with those ticks also replaces your short links, clicks, settings and the other ticked items with the backup's. Clicks recorded since the backup would be lost.
:::

Link Manager › Settings › Backup & restore

1. On the **Restore** card, select **Restore**.
2. Choose your backup file.
3. Under **What to restore**, tick **Posts and pages** and untick every other item.
4. Tick the box below the list that starts with "I understand that restoring posts".
5. Select **Restore**, then **Restore** again in the confirmation.

The full steps and what each item replaces are on [Backup and restore](https://docs.linkmanagerpro.com/guides/backup-restore#restore-a-link-manager-pro-backup).

## Details

| What | How it works |
|---|---|
| Content checked | Posts and pages. Other content types are never masked |
| Statuses checked | Published, scheduled and private. Drafts and pending posts are left alone |
| **Posts and pages to check** | Counts every author's posts in those statuses. The WP-CLI dry run shows the same count |
| Batches | **Scan posts**: 20 posts per request. `link`: 100 posts per batch (`--per-batch`). After 20 seconds, a request or batch stops starting new posts, and the next one carries on |
| Settings used | **Mask internal links**, both prefixes, **Slug length**, your Redirection `rel` rules and your affiliates. **Mask links when saving posts** doesn't need to be on |
| Running it again | Links that are already short links stay as they are, and a post with nothing to change isn't saved again |
| Undo | WP-CLI `unlink` (the `rel` values masking added stay), or a restore of **Posts and pages** from a backup |

## Get more out of it

- Try one post before the whole site. With **Mask links when saving posts** on, open a post that has a few links to other sites and update it. Then view it on your site and check the links. Run **Scan posts** once that post looks right.
- Keep followed links to the sources you cite. There's no list of domains to skip, but a developer can skip single links with the `link_manager_pro_mask_url` filter ([Link masking](https://docs.linkmanagerpro.com/features/link-masking)). With the default **Nofollow** setting (**All links**), every masked link to another site gets `nofollow`. Turn **Nofollow** off to switch it to **Selected domains only**, then list your partners as bare domains like `shop.example.com` ([Add nofollow or sponsored](https://docs.linkmanagerpro.com/tutorials/nofollow-links)).
- Set up affiliates before you scan. On an affiliate's domain, a new short link gets the affiliate's tag and **Redirect type**. Links to your partners then come out of the scan ready ([Affiliates](https://docs.linkmanagerpro.com/guides/affiliates)).
- See which posts earn clicks. Each short link in a post carries the post's ID on the page. The link's report then lists the posts that send it clicks under **Top posts sending clicks**.
- Add your affiliates before you turn on the disclosure. With **Affiliate disclosure** on, a post of the types you chose shows the notice when it links to an affiliate's domain, directly or through a short link, or has a `sponsored` link. A short link to a site that isn't listed under **Affiliates** doesn't bring it ([Affiliate disclosure settings](https://docs.linkmanagerpro.com/guides/settings/disclosure)).

## If something goes wrong

- If the dialog says **The scan stopped before it finished**, then posts already scanned keep their changes. Check your connection and select **Scan posts** again.
- If the dialog says **The number of posts and pages to check couldn’t be loaded.**, then select **Retry**. You can also scan without it: the count shows while it runs.
- If the summary says posts were left as they were, then run the scan again for posts that changed during the scan. Ask an administrator about posts your account can't edit. Open posts whose save would also change their status or slug in the editor, for example a scheduled post whose time has passed.
- If a link didn't become a short link, then check it against [which links masking changes](https://docs.linkmanagerpro.com/features/link-masking#which-links-masking-changes-and-which-it-leaves-alone). Also check its post: it must be a post or page, and published, scheduled or private.
- If a masked link opens a 404 page, then it may have reused a short link that's scheduled or expired. Find that link under **Short Links** and check its dates.
- If `unlink` leaves short links in your posts, then you added them yourself (add `--restore-shortlinks`), or a prefix changed since masking ([WP-CLI commands](https://docs.linkmanagerpro.com/guides/wp-cli#if-something-goes-wrong)).

More fixes are on [Troubleshooting](https://docs.linkmanagerpro.com/troubleshooting).

## Related

- [Track clicks on a link](https://docs.linkmanagerpro.com/tutorials/track-link-clicks)
- [Short links in your posts](https://docs.linkmanagerpro.com/features/link-masking)
- [General settings](https://docs.linkmanagerpro.com/guides/settings/general)
- [WP-CLI commands](https://docs.linkmanagerpro.com/guides/wp-cli)
- [Troubleshooting](https://docs.linkmanagerpro.com/troubleshooting)
