the_shortlink

Sponsored Link

シングル記事のパーマリンクページで使用され、このテンプレートタグは、現在の記事のリンクを”URL shortening”で表示します。
デフォルトでは、これは/?p=1234のフォーマットのURLを意味しており、パーマリンクが有効になっている場合のみ表示されます。ただし、この機能は、仕様によって制限され、異なるフォーマット、カスタムフォーマット、あるいは、サードパーティのURL短縮サービスによって提供されているフォーマット内でさえ、リンクを提供するかもしれないプラグインによって活用されることを目的としています。

このタグはループ内で使用しなければなりません。

Sponsored Link

Used on single post permalink pages, this template tag displays a “URL shortening” link for the current post. By default, this will mean the URL has a format of /?p=1234, and will only appear if pretty permalinks are enabled. However, this feature is limited by design and intended to be leveraged by plugins that may offer links in a different format, a custom format, or even a format provided by a third-party URL shortening service.

This tag must be used in The Loop.

the_shortlinkのテンプレートタグ使用方法

<?php the_shortlink( $text, $title, $before, $after ); ?> 

the_shortlinkのパラメーター

$text

(string) (optional) 表示するためのテキストリンクです。

(string) (optional) Link text to display.

Default: ‘This is the short link.’

$title

(string) (optional) リンクで表示されたツールチップテキストです。

(string) (optional) Tool-tip text displayed with the link.

Default: post title

$before

(string) (optional) リンクを追加するHTMLプレフィックスあるいはテキストです。

(string) (optional) Text or HTML prefix added to the link.

Default: None

$after

(string) (optional) リンクを追加するHTMLサフィックスあるいはテキストです。

(string) (optional) Text or HTML suffix added to the link.

Default: None

デフォルトの使い方

テキストとして、”The is the short link.”でリンクを表示します。

Displays link with “The is the short link.” as the text.

The is the short link.
<?php the_shortlink(); ?>

カスタムテキスト

指定したテキストでリンクを表示します。

Displays link with the specified text.

Shortlinkage FTW
<?php the_shortlink(__('Shortlinkage FTW')); ?> 

条件付きのHTML

shortlinkURLが利用可能な時のみ表示され、プレフィックスとサフィックスのHTMLでリンクを表示します。

Displays link with prefix and suffix HTML that will appear only when the shortlink URL is available.

short link
<?php the_shortlink('short link', null, '<ul><li>', '</li></ul>'); ?> 

ソースファイル

the_shortlink()は、wp-includes/link-template.php内に位置しています。

the_shortlink() is located in wp-includes/link-template.php.

変更ログ

Since: 3.0.0

関連テンプレートタグ

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss, wp_link_pages, next_post_link, next_posts_link, previous_post_link, previous_posts_link, posts_nav_link, sticky_class, the_meta

Sponsored Link