wppaste
WordPress

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

Since
2.1.0
Source
wp-includes/author-template.php:364
Retrieves the URL to the author page for the user with the ID provided.

Parameters

$author_idint
Author ID.
$author_nicenamestringoptional
The author's nicename (slug). Default empty.Default: ''

Return

string
The URL to the author's page.

Hooks fired · 1

One hook fires while get_author_posts_url() runs, in this order:

  1. apply_filters( author_link )filterline 393 (+29 into the body)

    Filters the URL to the author's page.

Uses · 4

  • home_url()Retrieves the URL for the current site where the front end is accessible.
  • get_userdata()Retrieves user info by user ID.
  • user_trailingslashit()Retrieves a trailing-slashed string if the site is set for adding trailing slashes.
  • apply_filters()Calls the callback functions that have been added to a filter hook.

Used by · 27

Show all 27

Source

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;}

History

Introduced in 2.1.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 tag, from src/wp-includes/author-template.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.