WordPress V4.0+Template Tag Reference Guide as of Version 4.2
Presented by DBS > Interactive Development :
Shortlink Tags
The Shortlinkthe_shortlink();
Used on single post permalink pages, this template tag displays a "URL shortening" link for the current post. By default, this will mean the URL has a format of /?p=1234, and will only appear if pretty permalinks are enabled. However, this feature is limited by design and intended to be leveraged by plugins that may offer links in a different format, a custom format, or even a format provided by a third-party URL shortening service.
<?php the_shortlink($text, $title, $before, $after); ?>
$text
String • Default: 'This is the short link.'
(Optional) Link text to display.
$title
String • Default: post title
(Optional) Tool-tip text displayed with the link.
$before
String • Default: none
(Optional) Text or HTML prefix added to the link.
$after
String • Default: none
(Optional) Text or HTML suffix added to the link.
WP Get Shortlinkwp_get_shortlink();
Returns the Short Link to a post for use in PHP. It does NOT display the short link.
<?php wp_get_shortlink($id, $context, $allow_slugs); ?>
$id
Integer • Default: '0', which means the current post or blog
(Optional) A post or blog ID.
$context
String • Default: 'post'
(Optional) Whether the ID is a 'blog' ID, 'post' ID, or 'media' ID. If 'post', the post_type of the post is consulted. If 'query', the current query is consulted to determine the ID and context.
$allow_slugs
Boolean • Default: true
(Optional) Whether to allow post slugs in the shortlink.
WP Shortlink Headerwp_shortlink_header();
Send a Link: rel=shortlink header if a shortlink is defined for the current page. Attached to the wp action.
<?php wp_shortlink_header(); ?>
No parameters.
WP Shortlink WP Headwp_shortlink_wp_head();
Inject rel=shortlink into head if a shortlink is defined for the current page. Attached to the wp_head action.
<?php wp_shortlink_wp_head(); ?>
No parameters.