Advertisement

How to Remove links to WordPress’ internal

⏲️ Estimated reading time: 2 min

Table of Contents

To remove links to WordPress’ internal ‘shortlink’ URLs, follow these steps:

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:

  1. Open your theme’s header.php file.
  2. Look for: phpCopyEdit<link rel="shortlink" href="<?php echo wp_get_shortlink(); ?>" />
  3. Delete or comment out this line.

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.


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.


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');

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. 🚀

Report an issue (max 5 words):

We store the message, post link, time, and IP (for abuse prevention). No account required.

Live Referrers

Photo of author

Flo

How to Remove links to WordPress’ internal

Published

Update

Welcome to HelpZone.blog, your go-to hub for expert insights, practical tips, and in-depth guides across technology, lifestyle, business, entertainment, and more! Our team of passionate writers and industry experts is dedicated to bringing you the latest trends, how-to tutorials, and valuable advice to enhance your daily life. Whether you're exploring WordPress tricks, gaming insights, travel hacks, or investment strategies, HelpZone is here to empower you with knowledge. Stay informed, stay inspired because learning never stops! 🚀

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.