get_comment_author_link()
Gets the HTML link (<a>) to the author's site of the current comment. The anchor of the link will be the author's name. If the author did not specify their site when commenting, the function will return just the author's name, without a link.
Used By: comment_author_link()
Hooks from the function
Returns
String. The name of the comment author or the HTML link to the author's site.
Usage
echo get_comment_author_link( $comment_ID );
- $comment_ID(int/object)
- ID or object of the comment whose author's link needs to be obtained. By default, null - the current comment in the comment loop.
Default: null - the 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>
Note
Before returning the result, the function runs it through the filter get_comment_author_link.
Changelog
| Since 1.5.0 | Introduced. |
| Since 4.4.0 | Added the ability for $comment_id to also accept a WP_Comment object. |