WordPress is a solid content management system primarily for bloggers. It supports many parameters to cater different group of users. For example, you can change and access a WordPress post or page URL in different ways. Shortlink is one of the ways to access a post or page in WordPress. In this article, we will explain what is Shortlink and how to get shortlink of WordPress posts and pages.
What is Shortlink?
By hearing the word shortlink, one case easily confuse this with shortening the URL of WordPress posts. However, these two have no relation with each other. Cloaking is the process of masking a URL behind a shortened link on your domain. For example, you can cloak the affiliate link and show it with your own domain like below:
- Affiliate link: https://externalsite.com/username/tracking-id/
- Cloaked link: https://yoursite.com/recommened/product
We are not discussing this cloaking process in this article, you can checkout our earlier article on how to cloak affiliate links in WordPress. Shortlink in WordPress actually means the original identification WordPress assigns to a post, page or custom post type. This is also called “Plain” URL which is the default permalink option for a new WordPress installation. Below is the example of shortlink for an example post in WordPress:
- Permanent link – https://yoursite.com/example-post/
- Shortlink – https://yoursite.com/p=123
As you can see the slug (description after the domain name) for a shortlink is a numerical number automatically assigned by WordPress in a running sequence. You can continue to use the shortlink as your permalink structure by assigning it under “Settings > Permalinks” section.
Why You Need to Know Shortlinks?
For a regular usage there are no real need for knowing the shortlink of your posts and pages. However, there are certain situations you need this information:
- Many plugins need post ID or page ID for using in the filter. The numerical number used in the shortlink is your post or page ID.
- You can use the default shortlink as shortened URL to hide the descriptive part.
- You may want to remember, bookmark or link an important URL that has a length permalink. The easiest way here is to remember the ID number, so that you can use it with your domain with a prefix /?p=ID.
- WordPress stores post/page/custom post type’s content in wp_posts table. Shortlink is stored in the table as Global Unique Identifier (guid). Since this is available permanently, you use GUID in queries for quick filtering and searching in database.
Note: As you can see in the above screenshot, guid for pages is stored as /?page_id=123 format. However, you can still use the ID number as shortlink /?p=123 format to access the same page.
Let’s say, you have setup a permalink structure as “Day and name” and using the URL structure for your site as “https://yoursite.com/year/month/date/sample-post/”. After certain time, you have changed the setup to “Post name” and start using the URL structure like “https://yoursite.com/example-post/”. In both cases, the GUID or shortlink will remain same for a specific post. You can always use the shortlink to access the post regardless of the permalink structure you setup. This is very useful feature which you can make use of when sharing your URLs. For example, you can use shortlink in your eBooks and newsletters or share shortlink in social platform instead of the permalink. In this way, you can easily avoid 404 errors even you change the slug or permalink structure. For example, plugins like Jetpack sends shortlink to email subscribers like below.
How to Get Shortlink of WordPress Posts?
Earlier WordPress by default was showing “Shortlink” button below the post title. However, this button was remove from version 4.4 and you will not see this in both Classic and Gutenberg editors.
Getting Shortlinks in Gutenberg
When you create a new post using Gutenberg editor, you can see the shortlink as a permalink before saving or publishing the content. You can see the shortlink under “Posts > Permalink” section in the right sidebar.
However, this link will be changed to your permalink when save or publish the post. This will be a problem when you want to find the shortlink of an already published post. In this case, you can find the post ID and use it in shortlink syntax. When editing your post, check the browser’s address bar. You will find the URL something like below:
https://yoursite.com/wp-admin/post.php?post=5456&action=edit
The number 5456 is the post ID which you can use to make shortlink like below.
https://yoursite.com/?p=5456
You can also find the post ID without going to the editor screen. Go to “Posts > Posts” section and hover over the post title to find additional links. Again, hover over, “Edit” option to see the URL in the browser’s status bar. You will see the same URL that you see when editing in Gutenberg editor with a number.
When you have the post ID, you know how to make a shortlink from that.
Getting Shortlink in Classic Editor
The above method of getting shortlink from post ID will work regardless of the editor you use. However, if you like to have a Shortlink button in Classic editor to copy the link like earlier WordPress versions, you can use a plugin for this purpose.
- Go to “Plugins > Add New” section and search for “shortlink”.
- When you find the “Bring Back the Get Shortlink Button”, install and activate it. Remember, you should have already installed Classic Editor plugin to use this plugin.
- Edit the post that you want to get shortlink and you will find the “Get Shortlink” button is back next to the permalink.
- When you are creating a new post, you have to first save or publish it to see this “Get Shortlink” button.
- Click on the button and copy the shortlink from the pop-up that appears.
Final Words
We hope you got an overall idea of what is shortlink in WordPress site. You can easily find the shortlink in both Classic and Gutenberg editor. We recommend using this shortlink when communicating to users in emails so that you can avoid 404 errors.
Leave a Reply
Your email is safe with us.