Definition:
function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) {}
Display the Short Link for a Post
Must be called from inside "The Loop"
Parameters
- string $text: Optional The link text or HTML to be displayed. Defaults to ‘This is the short link.’
- string $title: Optional The tooltip for the link. Must be sanitized. Defaults to the sanitized post title.
- string $before: Optional HTML to display before the link.
- string $after: Optional HTML to display after the link.
Defined filters
- the_shortlink
apply_filters( 'the_shortlink', $link, $shortlink, $text, $title )
Source code
function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) { global $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>'; $link = apply_filters( 'the_shortlink', $link, $shortlink, $text, $title ); echo $before, $link, $after; } }
3041
No comments yet... Be the first to leave a reply!