get_author_posts_url()
Retrieve the URL to the author page for the user with the ID provided.
Used By: get_the_author_posts_link()
Hooks from the function
Return
String
. The URL to the author's page.
Usage
get_author_posts_url( $author_id, $author_nicename );
- $author_id(int) (required)
- Author ID.
- $author_nicename(string)
- The author's nicename (slug).
Default: ''
Examples
#1 Get a link to the page with the posts of author 5, whose nickname is "batmen":
$author_url = get_author_posts_url( 5, 'batmen' ); echo $author_url; // Outputs: http://example.com/author/batmen
#2 Display the link of the author page for the author of the current post
<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>
Most get_
functions are not escaped and require escaping for safe usage.
Notes
- Global. WP_Rewrite. $wp_rewrite WordPress rewrite component.
Changelog
Since 2.1.0 | Introduced. |