wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



the_shortlink › WordPress Function

Seit3.0.0
Veraltetn/v
the_shortlink ( $text = '', $title = '', $before = '', $after = '' )
Parameter: (4)
  • (string) $text Optional. The link text or HTML to be displayed. Defaults to 'This is the short link.'
    Erforderlich: Nein
    Standard: (leer)
  • (string) $title Unused.
    Erforderlich: Nein
    Standard: (leer)
  • (string) $before Optional. HTML to display before the link. Default empty.
    Erforderlich: Nein
    Standard: (leer)
  • (string) $after Optional. HTML to display after the link. Default empty.
    Erforderlich: Nein
    Standard: (leer)
Definiert in:
Codex:
Changelog:
  • 6.8.0

Displays the shortlink for a post.

Must be called from inside "The Loop" Call like the_shortlink( __( 'Shortlinkage FTW' ) )


Quellcode

function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) {
	$post = get_post();

	if ( empty( $text ) ) {
		$text = __( 'This is the short link.' );
	}

	$shortlink = wp_get_shortlink( $post->ID );

	if ( ! empty( $shortlink ) ) {
		$link = '<a rel="shortlink" href="' . esc_url( $shortlink ) . '">' . $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. Unused.
		 */
		$link = apply_filters( 'the_shortlink', $link, $shortlink, $text, $title );
		echo $before, $link, $after;
	}
}