comment_author_link()WP 0.71

Outputs the name of the comment author as a link to the URL provided when commenting.

comment_author_link() should be used inside the comments loop.

No Hooks.

Returns

null.

Usage

<?php comment_author_link( $comment_ID ); ?>
$comment_ID(int/object)
ID or object of the comment whose author's name needs to be displayed. By default, the name of the current commenter is displayed.
Default: ID of the current comment

Examples

0

#1 Display the name of the current commenter as a link to his page:

This will print author’s link with anchor tag.

<?php echo comment_author_link(); ?>

Output will:

<a href="https://example.com" rel="external nofollow" class="url">Author Name</a>

Use comment_author_url(), if you want to get only comment author’s url.

Changelog

Since 0.71 Introduced.
Since 4.4.0 Added the ability for $comment_id to also accept a WP_Comment object.

comment_author_link() code WP 6.9.1

function comment_author_link( $comment_id = 0 ) {
	echo get_comment_author_link( $comment_id );
}