wpseek.com
WordPress开发者和主题制作者的搜索引擎
the_shortlink › WordPress Function
Since3.0.0
已弃用n/a
› the_shortlink ( $text = '', $title = '', $before = '', $after = '' )
参数: (4) |
|
定义在: |
|
文档: |
Displays the shortlink for a post.
Must be called from inside "The Loop" Call like the_shortlink( __( 'Shortlinkage FTW' ) )Related Functions: the_author_link, wp_get_shortlink, get_shortcut_link, the_author_posts_link, get_the_author_link
源码
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 = '<a rel="shortlink" href="' . esc_url( $shortlink ) . '" title="' . $title . '">' . $text . '</a>'; /** * 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; } }