wp_shortlink_wp_head

函式
wp_shortlink_wp_head ( No parameters )

wp_shortlink_wp_head是一個函式,它在WordPress文章或頁面的”head”中新增一個元素,表示該文章或頁面的短連結的URL。

如果當前頁面定義了短連結,則將rel=shortlink注入到頁面head。

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

function wp_shortlink_wp_head() {
	$shortlink = wp_get_shortlink( 0, 'query' );

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

	echo "<link rel='shortlink' href='" . esc_url( $shortlink ) . "' />n";
}

常見問題

FAQs
檢視更多 >