функция
since 2.1.0
get_author_posts_url()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
get_author_posts_url( int $author_id, string $author_nicename = '' ): string
Описание
Получает URL страницы автора для пользователя с указанным ID.
Параметры
$author_id
int
обязательный
ID автора.
$author_nicename
string
необязательный
= ''
Nicename автора (слаг).
Возвращаемое значение
string
Исходный код
wp-includes/author-template.php:384
function get_author_posts_url( $author_id, $author_nicename = '' ) {
global $wp_rewrite;
$author_id = (int) $author_id;
$link = $wp_rewrite->get_author_permastruct();
if ( empty( $link ) ) {
$file = home_url( '/' );
$link = $file . '?author=' . $author_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 ) );
}
/**
* Filters 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 | Introduced. |

