get_author_posts_url()
get_author_posts_url( int $author_id, string $author_ni…
get_author_posts_url( int $author_id, string $author_nicename = ” )
检索具有所提供ID的用户的author页面的URL。
Retrieve the URL to the author page for the user with the ID provided.
检索具有所提供ID的用户的author页面的URL。
Retrieve the URL to the author page for the user with the ID provided.
目录锚点:#参数#返回#源码#笔记
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $author_id | (int) | 必需 | 作者ID。 |
| $author_nicename | (string) | 可选 | 作者的昵称(slug)。 |
返回(Return)
(string)作者页面的URL。
源码(Source)
/**
* Retrieve the URL to the author page for the user with the ID provided.
*
* @since 2.1.0
*
* @global WP_Rewrite $wp_rewrite
*
* @return string The URL to the author's page.
*/
function get_author_posts_url($author_id, $author_nicename = '') {
global $wp_rewrite;
$auth_ID = (int) $author_id;
$link = $wp_rewrite->get_author_permastruct();
if ( empty($link) ) {
$file = home_url( '/' );
$link = $file . '?author=' . $auth_ID;
} else {
if ( '' == $author_nicename ) {
$user = get_userdata($author_id);
if ( !empty($user->user_nicename) )
$author_nicename = $user->user_nicename;
}
$link = str_replace('%author%', $author_nicename, $link);
$link = home_url( user_trailingslashit( $link ) );
}
/**
* Filter the URL to the author's page.
*
* @since 2.1.0
*
* @param string $link The URL to the author's page.
* @param int $author_id The author's id.
* @param string $author_nicename The author's nice name.
*/
$link = apply_filters( 'author_link', $link, $author_id, $author_nicename );
return $link;
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 2.1.0 | wp-includes/author-template.php:343 | 9 | 6 |
笔记(Notes)
显示当前文章作者的作者页链接
显示当前文章作者的作者页链接
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

还没有任何评论,赶紧来占个楼吧!