Title: get_author_posts_url
Published: April 25, 2014
Last modified: August 20, 2026

---

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

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#wp--skip-link--target)

Retrieves the URL to the author page for the user with the ID provided.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#parameters)󠁿

 `$author_id`intrequired

Author ID.

`$author_nicename`stringoptional

The author’s nicename (slug).

Default:`''`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#return)󠁿

 string The URL to the author’s page.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#source)󠁿

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

[View all references](https://developer.wordpress.org/reference/files/wp-includes/author-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/author-template.php#L384)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/author-template.php#L384-L416)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#hooks)󠁿

 [apply_filters( ‘author_link’, string $link, int $author_id, string $author_nicename )](https://developer.wordpress.org/reference/hooks/author_link/)

Filters the URL to the author’s page.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#related)󠁿

| Uses | Description | 
| [user_trailingslashit()](https://developer.wordpress.org/reference/functions/user_trailingslashit/)`wp-includes/link-template.php` |

Retrieves a trailing-slashed string if the site is set for adding trailing slashes.

  | 
| [WP_Rewrite::get_author_permastruct()](https://developer.wordpress.org/reference/classes/wp_rewrite/get_author_permastruct/)`wp-includes/class-wp-rewrite.php` |

Retrieves the author permalink structure.

  | 
| [get_userdata()](https://developer.wordpress.org/reference/functions/get_userdata/)`wp-includes/pluggable.php` |

Retrieves user info by user ID.

  | 
| [home_url()](https://developer.wordpress.org/reference/functions/home_url/)`wp-includes/link-template.php` |

Retrieves the URL for the current site where the front end is accessible.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 3 more](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#)

| Used by | Description | 
| [WP_Sitemaps_Users::get_url_list()](https://developer.wordpress.org/reference/classes/wp_sitemaps_users/get_url_list/)`wp-includes/sitemaps/providers/class-wp-sitemaps-users.php` |

Gets a URL list for a user sitemap.

  | 
| [WP_REST_Users_Controller::prepare_item_for_response()](https://developer.wordpress.org/reference/classes/wp_rest_users_controller/prepare_item_for_response/)`wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php` |

Prepares a single user output for response.

  | 
| [get_oembed_response_data()](https://developer.wordpress.org/reference/functions/get_oembed_response_data/)`wp-includes/embed.php` |

Retrieves the oEmbed response data for a given post.

  | 
| [get_the_author_posts_link()](https://developer.wordpress.org/reference/functions/get_the_author_posts_link/)`wp-includes/author-template.php` |

Retrieves an HTML link to the author page of the current post’s author.

  | 
| [WP_Users_List_Table::single_row()](https://developer.wordpress.org/reference/classes/wp_users_list_table/single_row/)`wp-admin/includes/class-wp-users-list-table.php` |

Generates HTML for a single row on the users.php admin panel.

  | 
| [get_author_link()](https://developer.wordpress.org/reference/functions/get_author_link/)`wp-includes/deprecated.php` |

Returns or Prints link to the author’s posts.

  | 
| [get_author_feed_link()](https://developer.wordpress.org/reference/functions/get_author_feed_link/)`wp-includes/link-template.php` |

Retrieves the feed link for a given author.

  | 
| [wp_admin_bar_edit_menu()](https://developer.wordpress.org/reference/functions/wp_admin_bar_edit_menu/)`wp-includes/admin-bar.php` |

Provides an edit link for posts and terms.

  | 
| [redirect_canonical()](https://developer.wordpress.org/reference/functions/redirect_canonical/)`wp-includes/canonical.php` |

Redirects incoming links to the proper URL based on the site url.

  | 
| [wp_list_authors()](https://developer.wordpress.org/reference/functions/wp_list_authors/)`wp-includes/author-template.php` |

Lists all the authors of the site, with several options available.

  |

[Show 5 more](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.1.0](https://developer.wordpress.org/reference/since/2.1.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#comment-content-1009)
 2.    [Jon (Kenshino)](https://profiles.wordpress.org/kenshino/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/get_author_posts_url/#comment-1009)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_author_posts_url%2F%23comment-1009)
     Vote results for this note: 5[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_author_posts_url%2F%23comment-1009)
 4.  Display the link of the author page for the author of the current post
 5.      ```php
         <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>
         ```
     
 6.  Most get_ functions are not escaped and require escaping for safe usage.
 7.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_author_posts_url%2F%3Freplytocom%3D1009%23feedback-editor-1009)
 8.   [Skip to note 5 content](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#comment-content-5723)
 9.    [Arafat Jamil](https://profiles.wordpress.org/arafatjamil01/)  [  5 years ago  ](https://developer.wordpress.org/reference/functions/get_author_posts_url/#comment-5723)
 10. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_author_posts_url%2F%23comment-5723)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_author_posts_url%2F%23comment-5723)
 11. Link to the archive of posts created by the author of the current post.
 12.     ```php
         $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>
         ```
     
 13.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_author_posts_url%2F%3Freplytocom%3D5723%23feedback-editor-5723)
 14.  [Skip to note 6 content](https://developer.wordpress.org/reference/functions/get_author_posts_url/?output_format=md#comment-content-531)
 15.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/get_author_posts_url/#comment-531)
 16. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_author_posts_url%2F%23comment-531)
     Vote results for this note: -3[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_author_posts_url%2F%23comment-531)
 17. Display the link of the author page for the author of the current post
 18.     ```php
         <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>"><?php the_author(); ?></a>
         ```
     
 19.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_author_posts_url%2F%3Freplytocom%3D531%23feedback-editor-531)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_author_posts_url%2F)
before being able to contribute a note or feedback.