Image of a keyboard with yellow scissors and desk items

Creating and Using Shortlinks in WordPress

Have you ever tried to attach a link to a social media post, only to find that it takes up most of your allotted character count? Alternatively, maybe you’ve tried to send a referral link and cringed at the unsightly string of numbers and symbols. If so, you could probably benefit from using shortlinks.

Shortlinks are exactly what they sound like: shorter URLs that redirect to the actual URL for your page when clicked on. They offer a number of advantages, in addition to just being more concise. For example, they allow for robust tracking and analytics. 

In this article, we’ll cover the advantages (and disadvantages) of shortlinks, and walk you through how to create them right from your WordPress dashboard. Let’s get started!

Why Shorten Links?

There are a number of reasons you might want to shorten a URL. The first and most obvious is to make the link simpler. In situations where character count matters, such as with Twitter posts and small text boxes, a shorter URL enables you to fit in more useful content.

In a similar vein, shortlinks also look nicer. They have a clean appearance that users may find more trustworthy, especially if the actual URL is very long or contains a lot of random numbers and letters. The clean look of a shortlink gives the content a more professional appearance. You can even create your own custom shortlink domains that match your branding.

It’s also worth noting that many link shorteners offer useful analytics. You can track the number of times the link has been clicked on, the times and dates of those interactions, the types of devices that were used, and more. While these stats can also be tracked on your site with tools like Google Analytics, having them attached to links on other sites can be useful as well.

As with any strategy, shortlinks aren’t always the best choice. In some cases, you may find that you get more clicks when you use a full URL that provides a preview of the page’s content. We’d recommend trying out several types of links, and monitoring your analytics carefully to determine which approach is best for your audience.

How to Create Shortlinks in WordPress

You may already be familiar with third-party URL shorteners like Bitly. However, it’s also possible to create shortlinks directly from your WordPress dashboard.

Prior to version 4.4, the WordPress editor featured a button that created a shortlink to the page or post being edited. You can easily add this button back with a bit of code. Here’s how!

Step 1: Write the Shortlink Code

The code for the Get Shortlink button actually still exists in the WordPress files. It’s just been hidden from the editor. You can restore it using a simple hook:

add_filter( 'get_shortlink', function( $shortlink ) {return $shortlink;} );

This filter will display the Get Shortlink button in the WordPress editor. 

Step 2: Add Your Code to the functions.php File

The hook above needs to be added to the functions.php file of your WordPress theme. You can find this by heading to your WordPress dashboard, and clicking on Appearance > Theme Editor.

This will pull up the Edit Themes screen:

How to add code to functions.php file in WordPress

Find functions.php in the list on the right (it’s usually labeled “Theme Functions”), and add the shortlink code snippet to the bottom of the file:

How to find functions.php and add snippet in WordPress

Then click on Update File. Now, let’s see if it worked!

Step 3: Test to See If the Get Shortlink Button Appears

You should now see the Get Shortlink button near your page or post name when editing. Here’s what it looks like in the Classic editor:

Screenshot of "Get Shortlink" button in WordPress Classic editor

Selecting the button will display a dialog with the shortlink for the page, which you can copy and paste to share:

Screenshot of how to copy and past shortlink generated in WordPress

Note that this method will only show the button in the Classic Editor. If you’re using the Block Editor, you’ll have to use a plugin, which we’ll cover next.

Get Shortlinks Using a WordPress Shortlink Plugin

If you want to shorten your links without having to use the Classic Editor, or you just prefer to avoid using code, there are numerous shortlink plugins available for WordPress:

Pretty links plugin logo plus instructions on how to use

To show you how this process works, we’ll use the well-rated and user-friendly Pretty Links plugin as our example.

Step 1: Install the Plugin

First, head to your WordPress dashboard and click on Plugins > Add New. Search for the “Pretty Links” URL shortener plugin and install it. Don’t forget to activate it after installation!

Step 2: Shorten Your Link

Once you have the plugin installed and activated, a Pretty Links item will appear in your WordPress sidebar. Clicking it will bring you to a dashboard, where you can see all the links you’ve shortened.

To create a shortlink, click on Add New:

Screenshot of how to shorten links using Pretty Links

On this screen, you can enter the URL you want to shorten and edit the slug of the shortlink you’re creating. You can also add any notes you might need for later. 

The Advanced tab contains options for setting the link to ‘nofollow’, marking it as sponsored, enabling parameter forwarding, and turning on tracking. You can select the information icon to the right of each option to get more details on what it does:

Screenshot of how to set shortlinks to nofollow in WordPress

Once you’ve created a shortlink, the Pretty Links dashboard will show it, along with some quick options. You can also make a few edits from here, or quickly share the link in a tweet or email:

How to make quick edits in the Pretty Links dashboard

Upgrading to the Pro version of Pretty Links will enable some additional features such as categories and tags, but it’s not necessary if all you want to do is shorten URLs. 

Customize Your WordPress Site with WP Engine

Shortlinks are an excellent way to clean up your online presence and increase your analytics capabilities. However, there’s a lot more to creating an incredible digital experience than just optimizing your links. 

WP Engine offers comprehensive resources and a variety of WordPress hosting plans to help you deliver the best experience possible for your users!

Get started.

Build faster, protect your brand, and grow your business with a WordPress platform built to power remarkable online experiences.