Estimated reading time: 2 min
To remove links to WordPress’ internal ‘shortlink’ URLs, follow these steps:
Method 1: Disable Shortlinks via Functions.php
Go to your WordPress dashboard.
Navigate to Appearance > Theme Editor.
Open the functions.php
file of your active theme (preferably a child theme).
Add the following code at the end of the file:
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
remove_action('template_redirect', 'wp_shortlink_header', 11, 0);
Save the changes.
2: Modify Your Themeβs Header
If your theme explicitly includes shortlinks in the <head>
, remove them manually:
- Open your themeβs
header.php
file. - Look for: phpCopyEdit
<link rel="shortlink" href="<?php echo wp_get_shortlink(); ?>" />
- Delete or comment out this line.
3. Disable Shortlinks via a Plugin
If you prefer not to edit theme files, you can use a plugin like Disable Shortlinks or Remove WordPress Shortlinks. These plugins remove shortlinks automatically.
4. Remove Shortlinks from API Responses
If you also want to remove shortlinks from WordPress’ REST API responses, add this code to functions.php
:
add_filter('get_shortlink', '__return_false');
This prevents WordPress from generating shortlinks entirely.

5. Remove Shortlink from HTTP Headers
By default, WordPress may include shortlinks in the HTTP headers. To remove them, add this to functions.php
:
function remove_shortlink_http_header($headers) {
unset($headers['X-Shortlink']);
return $headers;
}
add_filter('wp_headers', 'remove_shortlink_http_header');
6. Verify the Changes of Shortlink
After making these modifications:
- Check your website source code (
Ctrl + U
in Chrome) to ensure no<link rel="shortlink">
tag exists. - Use browser developer tools (F12 > Network > Headers) to verify shortlinks arenβt in HTTP responses.
These steps ensure WordPress doesn’t generate or expose shortlinks anymore. π
Discover more from HelpZone
Subscribe to get the latest posts sent to your email.