2024年05月29日 建站教程
如何利用wordpress中的函数获取当前作者页面的链接url,下面web建站小编给大家简单介绍一下关于get_the_author_posts_link()函数的基本用法!
函数原型:
get_the_author_posts_link(): string
函数源码:
function get_the_author_posts_link() {
global $authordata;
if ( ! is_object( $authordata ) ) {
return '';
}
$link = sprintf(
'<a href="%1$s" title="%2$s" rel="author">%3$s</a>',
esc_url( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ),
/* translators: %s: Author's display name. */
esc_attr( sprintf( __( 'Posts by %s' ), get_the_author() ) ),
get_the_author()
);
return apply_filters( 'the_author_posts_link', $link );
}
包含钩子:
apply_filters( 'the_author_posts_link', string $link )
使用举例:
echo get_the_author_posts_link();
本文链接:http://so.lmcjl.com/news/5554/