the_shortlink
函数
the_shortlink ( $text = '', $title = '', $before = '', $after = '' )
- 参数
-
-
(string)
$text
Optional The link text or HTML to be displayed. Defaults to ‘This is the short link.’- Required: 否
- Default: (empty)
-
(string)
$title
Optional The tooltip for the link. Must be sanitized. Defaults to the sanitized post title.- Required: 否
- Default: (empty)
-
(string)
$before
Optional HTML to display before the link. Default empty.- Required: 否
- Default: (empty)
-
(string)
$after
Optional HTML to display after the link. Default empty.- Required: 否
- Default: (empty)
-
(string)
- 定义位置
-
-
wp-includes/link-template.php
, line 4140
-
wp-includes/link-template.php
- 引入
- 3.0.0
- 弃用
- –
显示一个文章的短链接。
必须从 “The Loop”中调用。
像the_shortlink( __( ‘Shortlinkage FTW’) 这样调用。)
function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) {
$post = get_post();
if ( empty( $text ) ) {
$text = __( 'This is the short link.' );
}
if ( empty( $title ) ) {
$title = the_title_attribute( array( 'echo' => false ) );
}
$shortlink = wp_get_shortlink( $post->ID );
if ( ! empty( $shortlink ) ) {
$link = '' . $text . '';
/**
* Filters the short link anchor tag for a post.
*
* @since 3.0.0
*
* @param string $link Shortlink anchor tag.
* @param string $shortlink Shortlink URL.
* @param string $text Shortlink's text.
* @param string $title Shortlink's title attribute.
*/
$link = apply_filters( 'the_shortlink', $link, $shortlink, $text, $title );
echo $before, $link, $after;
}
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。


