Warning: Trying to access array offset on false in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 216
get_author_posts_url() - 使用提供的ID检索用户的作者页面的URL - WordPress函数 - WordPress动力
当前浏览:首页 / WordPress函数 / get_author_posts_url()

get_author_posts_url( int $author_id, string $author_nicename = '' )

使用提供的ID检索用户的作者页面的URL


Warning: Undefined array key -1 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 185

Warning: Undefined array key 4 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 186

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "650ae00d9c1fad3fccc0887ab9025dcf" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "90bc51819c89f7657afbc48dce2e8b1c" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "05a767e1e80b3fbcaa4313c042c82dd3" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

author 作者more...

postsmore...

urlmore...


参数

$author_id

(int)
(必填)
作者ID

$author_nicename

(string)
(可选)
作者的nicename(slug)

默认值: ''


返回

(string) 指向作者页面的URL。



源码

查看源码 官方文档


更新日志

版本描述
2.1.0开始引入

使用示例

  • 示例1

    显示当前文章作者的作者页面链接

    <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" title="<?php echo esc_attr( get_the_author() ); ?>"><?php the_author(); ?></a>

    大多数 get_ 函数都不是转义函数,需要转义才能安全使用。

  • 示例2

    链接到当前文章作者创建的文章存档。

    $author_id  = get_post_field( 'post_author', get_the_ID() );
    <a href="<?php echo esc_url( get_author_posts_url( $author_id ) ); ?>"><?php the_author(); ?></a>
  • 示例3

    显示当前文章作者的作者页面链接

    <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>"><?php the_author(); ?></a>