wp_shortlink_header

函式
wp_shortlink_header ( No parameters )

wp_shortlink_header是一個函式,用於在WordPress文章或頁面的HTTP響應中新增一個連結頭,表示該文章或頁面的短連結的URL。

如果當前頁面定義了一個短連結,則傳送一個Link: rel=shortlink頭。

附在{@see ‘wp’}動作上。

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

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

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

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

常見問題

FAQs
檢視更多 >