Since WordPress 3.0, a new feature has been added to the WordPress core which supports shortlink. Short link, is the shorten version of URL for the web pages, where a SEO-friendly URL link with many keywords or terms been shorted to just a few characters after the domain name in URL.
In order to support pointing and redirection of shortlink to the post, WordPress includes and adds a line of HTML code as meta tag in the header of the frontend web content page, which has the following format:
<link rel=’shortlink’ href=’http://www.mydigitallife.info/?p=xxx’ />
If the blogger does not explicitly define the shortlink URL for the post, its default shortlink will be in the form of ?p=ID syntax, where ID represents ID number of the post or page in WordPress.
Shortlink URL can be called in the theme’s templates by WordPress with the_shortlink(); function. But for webmasters who do not use shortlink, the additional link meta line in the header is not useful, and unnecessary increase a few bytes of HTML pages that may waste bandwidth.
Webmasters can easily remove the shortlink link in the WordPress header by using one of the following tricks.
Method 1: Remove Shortlink via functions.php in WordPress Theme
Login to the web host, and navigate to /wp-content/themes/<active theme name>/ directory. Then edit the functions.php to include the following line of code:
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
Save the modified functions.php, and the shortlink code in header will be removed with immediate effect.
Method 2: Disable Shortlink via WordPress Plugin
Copy and paste the following text into a text editor, and save the file with a name ends with .php extension. For example, wp-no-shortlink.php.
Plugin Name: WordPress Header Shortlink Disabler
Plugin URI: http://www.mydigitallife.info/
Description: Remove shortlink hook added by wp_head() in in WordPress header.
Author: My Digital Life
Author URI: http://www.mydigitallife.info/
remove_action( ‘wp_head’, ‘wp_shortlink_wp_head’, 10, 0 ); // Remove WordPress shortlink on wp_head hook
Alternatively, just download the wp-no-shortlink.php.
Upload the file to /wp-content/plugins/ directory. Then go to WordPress Plugins page to activate the plugin. The shortlink will be disabled and removed once the plugin is activated.