Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Create a Short Link in WordPress (The Easy Way)

Do you want to create short links to your WordPress blog posts or pages?

Short links are useful for sharing in your emails, Facebook messages, and even text messages.

In this article, we will show you how to generate short links using a plugin, and how to add the ‘Get Shortlink’ button back to the classic WordPress editor.

How to Create a Short Link in WordPress

Why Create a Short Link in WordPress?

Sharing your web content on social media can build user engagement and bring new users to your website. But pasting in long links or URLs isn’t always the best way.

That’s because some social media platforms will limit the number of characters you can use. A shorter URL gives you extra space for more useful content, which can lead to more engagement and traffic to your WordPress website.

That’s why URL shortener services like Bitly and TinyURL were originally created. They take a long link and make it shorter so that it doesn’t take up as much space.

For example, if you’re using SEO-friendly URL structures, then you might have long URLs that look something like this:

https://www.wpbeginner.com/beginners-guide/self-hosted-wordpress-org-vs-free-wordpress-com-infograph/

Our short link for that post saves a lot of space:

http://wpbeg.in/b6xh7G

Note: We’re using a custom domain, wpbeg.in, for our short links, which is a bit more technical to set up and would require you to purchase another domain. We have a separate tutorial on how to create your own customized short URL.

In the past, WordPress made it easy to get a short link to your blog post or page. There was a Get Shortlink button located right next to the permalink area of the classic editor.

Get Shortlink Button in the Classic Editor

However, if you recently started your blog, then you will not see this feature on your WordPress site because it was removed after WordPress version 4.4. WordPress still creates the links, but the button has been removed.

Still, there are a few ways you can get short links for your WordPress posts and pages.

We’ll cover the best link shortener plugin, plus a couple of ways you can restore the ‘Get Shortlink’ button in the classic editor. Simply click the links below to jump straight to each option:

We’ll start with a method that works for everyone. The Pretty Links plugin is one of the best URL shorteners for WordPress. It doesn’t rely on the classic editor and will create its own short link out of any URL.

It works with all links, including pages outside of your blog or website. So, besides letting you share your own content, it’s also the perfect tool for shortening affiliate links.

To get started, you’ll need to install and activate the Pretty Links plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Note: There is a Pro version of Pretty Links with more powerful features like keyword auto-linking, link categories, and tags, but for this tutorial, we will be using the free version.

Once you activate the plugin, a Pretty Links section is added to your WordPress dashboard. To create your first short link, you need to go to the Pretty Links » Add Link page.

Next, you need to paste the original URL of the page you want to share into the ‘Target URL’ text field. A short Pretty Link is automatically created, but you can customize it if you’d like to make it more readable.

Paste the Original URL Into Target URL

Once you’ve created a few short links, you may not remember what they are all for.

So it’s a good idea to type in the title of the web page and consider writing some notes of anything you need to remember.

Fill in the Title and Notes

Once you have filled in the Pretty Links form, click the ‘Update’ button to activate the short link.

Click the Update Button to Activate the Short Link

You will now see a list of all of your Pretty Links. To copy one to the clipboard, just click on the ‘Copy’ icon at the right of the screen.

After that, you can paste it into any of your social media channels. Pretty Links will even keep track of how many clicks each link gets.

Copy the Short Link Using the Copy Icon

While Pretty Links has built-in analytics, you can further improve your analytics by connecting it with Google Analytics using the MonsterInsights plugin.

For more details, see our step by step guide on how to properly set up Google Analytics in WordPress.

This is a simple method of adding back the Get Shortlink button to the classic editor.

First, you need to install and activate the Bring Back the Shortlink Button plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, this plugin will automatically add the Get Shortlink button to the classic editor. To check that it worked, just edit any of your posts.

The Get Shortlink Button is Added to the Classic Editor

When you click the ‘Get Shortlink’ button, it will show you the WordPress Shortlink for your post or page.

Copy the Short Link to Share It with Your Audience

You can copy the link to the clipboard so you can share it with your audience in your emails and messages.

This method is for more advanced users and uses code rather than a plugin. It adds the Shortlink button to the classic editor by adding a custom code snippet to your theme’s functions.php file.

But, we don’t recommend editing your theme files to inexperienced users because if you make a mistake, then it could break your website.

Instead, we’ll use WPCode, which is the best code snippets plugin for WordPress. It makes it easy to add custom code in WordPress, without editing your theme files.

You can check out our guide on how to copy and paste code snippets in WordPress for more details.

First, you’ll need to install and activate the free WPCode plugin. For step by step instructions, see our tutorial on how to install a WordPress plugin.

Upon activation, the plugin will add a new menu item labeled ‘Code Snippets’ to your WordPress admin bar. Clicking on it will show you a list of all the custom code snippets you have saved on your site. Since you just installed the plugin, your list will be empty.

Go ahead and click on the ‘Add New’ button to add your first custom code snippet in WordPress.

Click the Add New Button to Add Your First Custom Code Snippet in WordPress

This will bring you to the ‘Add Snippet’ page. You can choose a code snippet from the built-in library or add your own custom code.

For this tutorial, choose the ‘Add Your Custom Code (New Snippet)’ option by clicking the ‘Use snippet’ button underneath it.

Add your new custom code snippet in WPCode

On the next screen, start by entering a title for your custom code snippet. Let’s call it ‘Short Link Button’. After you enter a title, simply copy and paste the code snippet below into the ‘Code Preview’ box.

add_filter( 'get_shortlink', function( $shortlink ) {return $shortlink;} );
Paste short link button code into the WPCode plugin

Don’t forget to choose ‘PHP Snippet’ from the drop-down list on the right side of the screen.

When you come across this snippet in the future, you may not remember what it’s for. So it’s a good idea to type something helpful in the notes section as a reminder.

Add notes for your custom code and tags for organization

You can also assign tags to your code snippet. This will help you sort your code snippets by topic and functionality.

Next, you can select how you want to insert the code. For this snippet, you’ll want to leave it on the ‘Auto Insert’ method so that the snippet will be automatically inserted and executed on your site.

Pick the insertion method for your custom code snippet

Finally, you need to toggle the switch from ‘Inactive’ to ‘Active’ in the top-right corner.

Then, click on the ‘Save Snippet’ button.

Save and activate your custom code snippet

Once the snippet is activated, the Shortlink button will be added to the classic editor.

It will display on all your published posts when you edit them.

The Shortlink Button Will Be Added

We hope this article helped you learn how to create a short link in WordPress. You might also like to learn how to get a free email domain, or see our comparison of the best domain name registrars.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

8 CommentsLeave a Reply

  1. Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. How to create a new field at the bottom of the article?
    Write a short link to the article
    And the short link next to the field

    • We do not have a specific solution for that at the moment but we will certainly share if we find something we would recommend :)

      Admin

  3. Hello,

    Thank you for the topic. I was using the manual method. But now it is not working with WP 5 Gutenberg editor.

    Is there a new way for it?

    Thank you

  4. I would love to see a “Get Shortlink” capability for the Admin Bar when logged in, so one does not have to go to the post/page editor to get the shortlink. Any gurus have any suggestions?

  5. Is it possible using a shortener to share a link blocked by Fb. And it works automatically for ‘share button’.

    My domain was blocked Fb when it encountered an interruption, it was fixed but still blocked, and the ‘share button for Fb’ on my page is no longer useful.

    Thank’s WpBeginner.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.