A Guide to Shortlinks for WordPress
READING TIME: MIN
Remember that time when that link you were trying to post on social media overshadowed the post itself, or you ran out of characters? And even if that didn’t happen, maybe the alphabet (and number and symbol) soup in the link string just didn’t go with the look you had in mind?
Sounds like you are (and were) in the market for shortlinks!
True to their name, shortlinks are shorter versions of links (URLs) that, when clicked, point to the actual (long, unwieldy) URL for the page.
Why Do You Even Need Shortlinks with WordPress?
Well, we did look at a couple of use cases up there, but here’s a more comprehensive set of reasons for choosing the shortlink life:
- Character Counts and Simplification
- Aesthetics
- Analytics
Character Counts and Simplification – Let’s get the obvious one out of the way – yes, every time you have a Twitter post or tiny text box situation, the trusty shortlink has you covered. The URL gets put in its comfy space, and your text can really shine.
Aesthetics – Shortlinks are quite a bit easier on the eye. They look tidy, reliable and manageable, particularly when the original URL looks like a mess. Add to that the convenience of putting your brand front and center with custom shortlinks, and it’s obvious why you need them.
Analytics – If you’d like to track metrics like numbers, dates and times of clicks or client devices used, a lot of link shorteners will let you do just that. You can of course use Google Analytics to achieve the same result, but it never hurts to have multiple sets of digital eyes on your data.
Disclaimer, though: A shortlink isn’t a cure-all. Sometimes the page preview that a full URL can provide brings more value (and clicks) to the table. Feel free to try out both and see what works for your specific needs.
Creating Shortlinks in WordPress
Bitly and all the other third party link-shorteners are all over the internet landscape, but we can get our own shortlinks made from right inside WordPress.
WordPress versions before 4.4 had a button to create and assign a shortlink to the page in question. The good news is that we can bring that button back with just a little code. Read on:
The code itself.
This part is pretty easy because the code is still present in WordPress’s files, just not visible in the editor. A quick and easy filter will fix this, and the ‘Get Shortlink’ button should be visible:
add_filter( 'get_shortlink', function( $shortlink ) {return $shortlink;} );
Adding it to the theme.
Head over to the WordPress dashboard, and find the ‘Theme Editor’ under ‘Appearance’. In the ‘Edit Themes’ screen that pops up, the list on the right will contain the functions.php file, usually named ‘Theme Functions’. Here, at the bottom of this file, you can add on the above code hook. Choose ‘Update File’ to finish.
Checking whether the code works.
If we did everything as described, there should now be a ‘Get Shortlink’ button in the Classic Editor view of posts, next to the post name. Clicking on the button will provide you with the shortlink and you can copy it.
Using a Plugin for Shortlinks
Remember we said that the button would show up in the ‘Classic Editor’ view? That’s because it doesn’t show up in the ‘Block Editor’ view, and we’ll need a plugin to get that done. Luckily, while there’s more than one plugin that does this, we’ve picked the popular and convenient Pretty Links plugin for our purposes. Here’s how to use it:
- Installation. On the WordPress dashboard, select ‘Plugins’, and choose ‘Add New’. Search for ‘Pretty Links’, install and activate it.
- Create the Shortlink.
- Find ‘Pretty Links’ on your sidebar, and follow it to its own dashboard, which displays all the shortlinks you’ve created.
- Choose ‘Add New’, enter the original URL, and edit the URL slug for your shortlink – the slug being the part of the URL that’s right after the domain name.
- In the ‘Advanced’ tab, there are options like setting the link to be ‘sponsored’, activating tracking or parameter forwarding, and marking the link ‘nofollow’.
Your new shortlink will be visible in the Pretty Links dashboard, with options, edits possible, and the choice to share it via Twitter and email. Pretty Links Pro adds some features, but you won’t need them if you’re just after shortlinks.
And that wraps it up for this overview on Shortlinks for WordPress. We’ll see you next time with more WordPress tips!
More on The Topic
- How PHP Powers Enterprise WordPress Development for Scalable and Custom Solutions
- Why WordPress and Next.js Integration is the Future of Enterprise Websites
- WordPress for Advanced Business Applications: Integration and Customization Insights
- WordPress as a Transformation Tool for Enterprise Digital Platforms
- WordPress Solutions for Multi-Faceted Enterprise Challenges