WordPress get_author_posts_url() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
Template tag

Definition

In WordPress, get_author_posts_url() returns the web address (URL) of an author archive page. That page lists all posts written by one author.

It returns the URL. It does not print it. Use echo with esc_url() to show the link. Pass the author ID. Inside The Loop you can get it with get_the_author_meta( 'ID' ).

Syntax

Pass the author ID. You can also pass the author nicename (the URL-friendly name).

WordPress
get_author_posts_url( $author_id );
get_author_posts_url( $author_id, $author_nicename );
CallWhat it does
get_author_posts_url( $id )Builds the archive URL for the author with this ID.
get_author_posts_url( $id, $slug )Same, but you give the nicename so WordPress does not have to look it up.

This function is not an echo tag. Print the result with echo esc_url( ... ).

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

Parameters

ParameterDescription
$author_idRequired. The user ID of the author.
$author_nicenameOptional. The author's URL-friendly name (user_nicename). Leave it out and WordPress finds it for you.

Return Value

Return ValueDescription
stringThe URL of the author archive, for example https://example.com/author/mari-selvan/.

WordPress Examples

Three short theme examples. Each one has a sample output.

Example 1 — Basic link

Get the archive URL for the current post author and use it in a link.

WordPress
<?php
$author_id = get_the_author_meta( 'ID' );
$url       = get_author_posts_url( $author_id );
?>
<a href="<?php echo esc_url( $url ); ?>">More posts by this author</a>

How It Works

  1. get_the_author_meta( 'ID' ) returns the ID of the current post author.
  2. get_author_posts_url() returns the archive URL for that ID.
  3. esc_url() makes the URL safe to print.

Example 2 — Link with the author name

Show a link such as "All posts by Mari Selvan".

WordPress
<?php
printf(
  '<a href="%s">All posts by %s</a>',
  esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
  esc_html( get_the_author() )
);
?>

How It Works

  1. printf() puts the URL and the name into the link text.
  2. get_the_author() returns the display name.
  3. Each value is escaped before it is printed.

Example 3 — Fixed author ID and nicename

Link to one known author, even outside The Loop.

WordPress
<?php
$url = get_author_posts_url( 1, 'mari-selvan' );
echo esc_url( $url );
?>

How It Works

  1. The first value is the user ID.
  2. The second value is the nicename, so WordPress skips the lookup.
  3. This works in a footer or sidebar because it does not need The Loop.

Frequently Asked Questions

It returns the URL of an author archive page. That page lists all posts by one author.
No. It only returns the URL. Use echo esc_url( get_author_posts_url( $id ) ) to print it.
Use get_the_author_meta( 'ID' ). It returns the ID of the current post author.
No. If you leave it out, WordPress finds the nicename from the author ID.
get_author_posts_url() gives an archive URL on your own site. get_the_author_link() gives a link to the website the author added in their profile.
Use the_author_posts_link(). It prints a full link with the author name as the text.

Next: get_the_author()

Return a link to the author's website, or just the name.

get_the_author() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful