By default, WordPress adds <link rel="shortlink">
meta tag to the <head>
of a website and uses the short url like https://mixable.blog/?p=4803
for this. When you already use nice slugs as permalink structure, such a tag is not necessary, because you already have unique urls.
To remove the shortlink tag, you can use an additional plugin or simply add some code to your themes functions.php
:
PHP
add_filter('after_setup_theme', 'remove_redundant_shortlink');
function remove_redundant_shortlink() {
// Remove HTML meta tag
// <link rel='shortlink' href='http://mixable.blog/?p=12345' />
remove_action('wp_head', 'wp_shortlink_wp_head', 10);
// Remove HTTP header
// Link: <https://mixable.blog/?p=12345>; rel=shortlink
remove_action( 'template_redirect', 'wp_shortlink_header', 11);
}
This code will also remove a http header from each response.
Foto von Markus Winkler auf Unsplash
Leave a Reply