The get_the_author_posts_link() WordPress PHP function retrieves an HTML link to the author page of the current post’s author.
Usage
echo get_the_author_posts_link();
Parameters
- None
More information
See WordPress Developer Resources: get_the_author_posts_link()
Examples
Display Author Posts Link in a Post Template
Display the author posts link in a post template.
if ( function_exists( 'get_the_author_posts_link' ) ) { echo 'Posted by: ' . get_the_author_posts_link(); }
Show Author Posts Link with Custom Text
Show the author posts link with custom text.
$author_posts_link = get_the_author_posts_link(); echo 'Check out more posts by ' . $author_posts_link . '!';
Add an Icon to the Author Posts Link
Add an icon to the author posts link using Font Awesome.
$author_posts_link = get_the_author_posts_link(); echo '<i class="fas fa-user"></i> ' . $author_posts_link;
Display Author Posts Link in a Loop
Display the author posts link for each post in a loop.
if ( have_posts() ) { while ( have_posts() ) { the_post(); echo 'Author: ' . get_the_author_posts_link() . '<br>'; } }
Add a Conditional for Author Posts Link
Add a conditional statement to only display the author posts link if the function exists.
if ( function_exists( 'get_the_author_posts_link' ) ) { echo 'Author: ' . get_the_author_posts_link(); } else { echo 'Author: ' . get_the_author(); }