wp_shortlink_header()
Creates a header response Link: rel=shortlink in which the value is set to the short link for the current пост.
Triggered on the hook template_redirect:
add_action( 'template_redirect', 'wp_shortlink_header', 11, 0 );
Uses: wp_get_shortlink()
No Hooks.
Returns
null. Nothing (null).
Usage
wp_shortlink_header();
Examples
#1 Remove the short link to the current post from the server response header
remove_action( 'template_redirect', 'wp_shortlink_header', 11 );
Changelog
| Since 3.0.0 | Introduced. |
wp_shortlink_header() wp shortlink header code WP 7.0
function wp_shortlink_header() {
if ( headers_sent() ) {
return;
}
$shortlink = wp_get_shortlink( 0, 'query' );
if ( empty( $shortlink ) ) {
return;
}
header( 'Link: <' . $shortlink . '>; rel=shortlink', false );
} 