
如何使用Poedit翻译WordPress主题
the_shortlink ( $text = '', $title = '', $before = '', $after = '' )
shortlink是一个WordPress函数,用于检索当前文章或指定文章的短链接。它可以用于为用户提供一个缩短的URL,以便在社交媒体上轻松共享。
显示一个文章的短链接。
必须从”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 = '<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; } }