
WordPress主题开发入门基础教程
get_the_author_link ( No parameters )
get_the_author_link: 这个函数检索到文章作者的档案页的链接。它不接受任何参数,返回一个HTML格式的链接。
检索作者的链接或作者的名字。
如果作者设置了主页,返回一个HTML链接,否则只返回作者的名字。
function get_the_author_link() { if ( get_the_author_meta( 'url' ) ) { global $authordata; $author_url = get_the_author_meta( 'url' ); $author_display_name = get_the_author(); $link = sprintf( '<a href="%1$s" title="%2$s" rel="author external">%3$s</a>', esc_url( $author_url ), /* translators: %s: Author's display name. */ esc_attr( sprintf( __( 'Visit %s’s website' ), $author_display_name ) ), $author_display_name ); /** * Filters the author URL link HTML. * * @since 6.0.0 * * @param string $link The default rendered author HTML link. * @param string $author_url Author's URL. * @param WP_User $authordata Author user data. */ return apply_filters( 'the_author_link', $link, $author_url, $authordata ); } else { return get_the_author(); } }