wp_shortlink_header()WP 3.0.0

Sends a Link: rel=shortlink header if a shortlink is defined for the current page.

Attached to the wp action.

No Hooks.

Return

null. Nothing (null).

Usage

wp_shortlink_header();

Examples

0

#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() code WP 6.5.4

function wp_shortlink_header() {
	if ( headers_sent() ) {
		return;
	}

	$shortlink = wp_get_shortlink( 0, 'query' );

	if ( empty( $shortlink ) ) {
		return;
	}

	header( 'Link: <' . $shortlink . '>; rel=shortlink', false );
}