BIOS,Windows, Linux, Software,Security, Domains, Web Hosting

How to Remove Shortlink in WordPress

Shortlink is a new feature since wordpress 3.0, many people like it, and more people do not need it really, so you can enable or disable your shortlinks in wordpress.

1. Definition of Shortlink in Wordpress

Note: In wordpress 3.0 or later edition, shortlink feature is opened by default. You do not need any settings about it, if you want to take a look at it, just open the permalink to a customized structure. and then publish a new post and edit it, you will find the shortlink tip.

In file "wp-admin\edit-form-advanced.php", there is paragraph code just like this.

$sample_permalink_html = $post_type_object->public ? get_sample_permalink_html($post->ID) : '';
$shortlink = wp_get_shortlink($post->ID, 'post');
$permalink = get_permalink( $post->ID );

These codes is to display a shortlink button, the funciton of wp_get_shortlink is defined in wp-includes/link-template.php.

Relate functions list here:

  • wp_get_shortlink - Return a shortlink for a post, page, attachment, or blog.
  • wp_shortlink_wp_head - Inject "<link rel='shortlink' href='shortlink' />" into head if a shortlink is defined for the current page.
  • wp_shortlink_header - Send a Link: rel=shortlink header if a shortlink is defined for the current page.
  • the_shortlink - Display the Short Link for a Post

So if you want to integrate shortlink in your themes:

  • Add  "the_shortlink( __('Text You want to display'), __('Tip text'))" in your themes.
  • Add "add_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );"  in your functions.php.

Introduction of the_shortlink():

<?php the_shortlink( $text, $title, $before, $after ); ?>

if you need to compatible with older edition wordpress, you can add a judgment´╝Ü

if(function_exists('the_shortlink') ).

Four parameters list here:

  • text - Dispaly text, default is "This is the short link."
  • title - Tip text, default is the tile of post.
  • before - something added before the shortlink.
  • after - something added after the shortlink.

refer to the next example for detail. More Links:


If I want to output these code:

<ul><li><a rel="shortlink" href="http://localhost/?p=123" title="I am ShortLink">Visit to ShortLink</a></li></ul>

The shortlink code added in my themes:

<?php the_shortlink( 'Visit to ShortLink', 'I am ShortLink', '<ul><li>', '</li></ul>' ); ?>

2. How to Disable/Remove Shortlinks in Wordpress

If you want to disable shortlinks,  Add this in your functions.php:

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


Leave a Reply

Subscribe to BootBeta Comments RSS feed to receive notification of latest comments posted.


  • Enter Email Address:

Recent Post

Copyright@ 2010-2014 Bootbeta All Rights Reserved.
HooBlog Ver 1.5 Build 20140530