Monday , June 24 2024

How to Remove the Shortlink from the HTTP Header in WordPress Without Plugin

The format of shortlink is very simple. It contains your domain name and page ID. The output looks like the following line.
<link rel='shortlink' href='' />

To remove the shortlink from the HTTP header of your WordPress website, you can add the following code to your active theme’s functions.php file:

remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);


remove_action('template_redirect', 'wp_shortlink_header', 11);

This code will remove the wp_shortlink_wp_head action from the wp_head hook, which is responsible for adding the shortlink to the HTTP header.

Alternatively, you can use a plugin such as “Header and Footer Scripts” to remove the shortlink from the HTTP header without editing your theme files.

It is worth noting that removing the shortlink may affect some features or plugins that rely on it, such as some social media sharing plugins. Therefore, it is recommended to test your website thoroughly after removing the shortlink to ensure everything is still functioning properly.

Check Also

How to remove WordPress REST API links without Plugin

What is the WordPress REST API? The WordPress REST API is a programming interface that …

Leave a Reply

Your email address will not be published. Required fields are marked *