wp_shortlink_header() WordPress Function

The wp_shortlink_header() function allows you to output a short link for the current page. This is useful for sharing links to content on your site, as the short link will be easier to remember and share than the full URL.

wp_shortlink_header() #

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


Description

Attached to the ‘wp’ action.


Top ↑

Source

File: wp-includes/link-template.php

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

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

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

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


Top ↑

Changelog

Changelog
VersionDescription
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More