wp_shortlink_wp_head()
Outputs a short link of the post as meta information. It is customary to output it in the HEAD part of the page.
Example of what the function outputs:
<link rel='shortlink' href='http://example.com/?p=253' />
The function is automatically called on the hook wp_head:
add_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
Uses: wp_get_shortlink()
No Hooks.
Returns
null. Nothing (null). Outputs text on the screen.
Usage
wp_shortlink_wp_head();
Examples
#1 Cancel the short link to the post in the HTML <head> part of the web page
remove_action( 'wp_head', 'wp_shortlink_wp_head' );
Changelog
| Since 3.0.0 | Introduced. |
wp_shortlink_wp_head() wp shortlink wp head code WP 7.0
function wp_shortlink_wp_head() {
$shortlink = wp_get_shortlink( 0, 'query' );
if ( empty( $shortlink ) ) {
return;
}
echo "<link rel='shortlink' href='" . esc_url( $shortlink ) . "' />\n";
}