get_comment_author_link()
Retrieve the HTML link to the URL of the author of the current comment.
Both get_comment_author_url() and get_comment_author() rely on get_comment(), which falls back to the global comment variable if the $comment_ID argument is empty.
Used By: comment_author_link()
Hooks from the function
Return
String
. The comment author name or HTML link for author's URL.
Usage
get_comment_author_link( $comment_ID );
- $comment_ID(int|WP_Comment)
- WP_Comment or the ID of the comment for which to get the author's link.
Default: current comment
Examples
#1 Get the name of the author of the comment as a link to the site
Suppose in the comment loop we need to display the name of the author of the comment as a link to his site:
$author = get_comment_author_link(); echo $author; /* Result: <a href="http://author-example.com/" rel="external nofollow" class="url">Eugene</a> If the author doesn't have a link to the site, result will be: Eugene */
#2 Specify the comment ID
$author = get_comment_author_link( 76 ); echo $author; // Returns: <a href="http://author-example.com/" rel="external nofollow" class="url">Eugene</a>
Changelog
Since 1.5.0 | Introduced. |
Since 4.4.0 | Added the ability for $comment_ID to also accept a WP_Comment object. |