Skip to content

Share buttons

Bitly short links for share buttons: getting an access token

By Hannah Voss, Editor · Reviewed September 2026 · 5 min read

Quick answer

To use Bitly short links in share buttons, sign in to Bitly, open your account settings, find the API or developer section, and generate an access token after confirming your password. Paste that token into your sharing plugin's short link setting, then clear caches. Short links are optional: most networks shorten links themselves.

A long grey paper strip unfolded in wide pleats beside the same kind of strip folded tightly into a short compact block

Before networks shortened links automatically, long addresses ate into character limits and looked messy in posts. Share plugins added short link integrations, such as the MashShare ShortURLs add-on, which called the Bitly API with the site owner's token and stored the result. The documentation article on getting a Bitly access token was the most linked page on this domain's old knowledge base, so this guide covers the same task as it works now.

How a plugin turns a post address into a short link01Long post URLyour permalink02Bitly APIwith your token03Short linkbit.ly/...04Storedreused for shares
The plugin asks once per post and should store the answer, so the token is not used on every page view.

Get the Bitly access token

  1. Sign in

    Log in to your Bitly account in a browser.

  2. Open settings

    Go to your account or profile settings. The token lives in a section named for the API or developer settings; the exact label has changed over the years.

  3. Generate a token

    Choose to generate an access token and confirm your password. Copy the token straight away; treat it like a password.

  4. Paste it into your plugin

    Open your sharing or short link plugin settings, paste the token in the Bitly field, and save.

  5. Clear caches and test

    Purge page caches, share a test post, and check that the link in the share dialog is the short version.

Worked example: what the plugin does with the token

Behind the settings field, a plugin makes one request per post to the shortening endpoint documented in the Bitly API reference, sending the long URL and the token as a bearer credential, and stores the returned short link in post meta. Testing the token yourself with the same call is the quickest way to tell a plugin problem from an account problem.

curl -X POST https://api-ssl.bitly.com/v4/shorten \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"long_url": "https://example.com/2026/share-links/"}'

# a working token returns JSON containing "link": "https://bit.ly/..."
# 403 FORBIDDEN means the token is wrong or revoked; 429 means the plan's rate limit was hit

The numbers below are invented but the ratio is the point. A site with 340 published posts and 12,000 page views a month needs 340 calls in total if the plugin stores each short link, plus one per new post. A plugin that shortens on every page view instead makes 12,000 calls a month, hits rate limits, and slows every uncached load while it waits for the API.

Plugin behaviourAPI calls per monthEffect on page loadVerdict
Shorten once, store in post meta340 plus new postsNone after the first requestCorrect
Shorten on publish onlyAbout 20 (new posts)NoneCorrect, if old posts are back-filled
Shorten on every uncached page buildHundreds to thousandsAdds an API round trip per cache missReplace the plugin
Shorten in the browser on clickOne per share clickNone on load, delay on clickExposes the token; avoid
SymptomLikely causeFix
Long link still usedToken missing or pasted with a spacePaste again, save, clear caches
Works for old posts, not newMonthly link quota reached on the planCheck the plan's limits in the account
Errors after months of workingToken revoked or account password resetGenerate a new token
Slow pagesPlugin calls the API on page loadUse a plugin that stores links per post

Probably not for sharing. X wraps every link and counts it as 23 characters regardless of length. Facebook and LinkedIn show a preview card, not the raw address. Short links still help when you want click statistics per campaign or a branded domain, but that is a marketing choice, not something share buttons require.

What goes wrong

  • Token in the wrong field. Some plugins have separate fields for a legacy login and API key pair and for the newer access token. Only the token field works with the current API.
  • Token pasted into a public place. A token in a theme file, a page's HTML or a browser script lets anyone shorten links on your account. Keep it in the plugin's settings, which are stored in the database.
  • Cache serving the long link. The token works, the short link is stored, and the page still shows the long one because the cached HTML predates it. Purge after saving.
  • Short links pointing at staging. Links created while the site ran on a staging domain keep pointing there. Regenerate them after a domain move.
  • Tracking parameters baked in. If the plugin appends campaign parameters before shortening, every short link carries them for ever. Decide the parameters first; see tracking shares in analytics.

Check it worked

  • The test request above returns a link, not a 403.
  • A newly published post shows a short link in the share dialog after one page load.
  • Reloading the post ten times makes no further API call, visible in the plugin's log or a query monitor.
  • The short link resolves to the canonical post URL, on the live domain, with only the parameters you intended.
  • The token appears nowhere in the page source.

If the goal was shorter posts on X, click to tweet boxes explain why every link already counts as 23 characters. The row the short link ends up in is set up in adding share buttons to WordPress, and other integrations are indexed on the share buttons hub.

Sources

Questions

Where do I find my Bitly access token?

In your Bitly account settings, under the API or developer section. Generate a token and confirm your password.

Why are my share buttons not using Bitly links?

Usually the token is missing, has a stray space, was revoked, or your plan's monthly limit was reached. Caches can also serve the old link.

Do I need short links for X?

No. X counts every link as 23 characters, whatever its length.

How do I test whether my Bitly token works?

Send one shorten request to the API with the token as a bearer credential, as in the example above. A link in the response means the token is fine and the problem is in the plugin or cache.

Is it safe to put a Bitly token in a plugin?

Yes, if the plugin stores it in the database and uses it only on the server. Never place the token in theme files or browser scripts, where anyone can read it.

Share this guide

Hannah Voss, Editor. Checks every guide against a working WordPress install and the networks' current documentation. Last reviewed September 2026.

  1. How to add social share buttons to WordPressAdd social share buttons to WordPress with a plugin, a block, or plain links in your theme. Placement, networks, counts and the checks to run afterwards.6 min read
  2. Click to tweet boxes: how to build them in WordPressBuild a click to tweet box in WordPress with a block or a simple link. Wording, the 280 character limit, how links are counted, and how to style the quote.5 min read
  3. Tracking shares and pageviews in analyticsTrack share button clicks as analytics events, tag shared links with campaign parameters, and read shared traffic in referrer reports without cookies.5 min read