comment_link()WP 1.5.0

Display the link to the comments.

1 time — 0.053325 sec (extremely slow) | 50000 times — 9.37 sec (fast)
Hooks from the function

Return

null. Nothing (null).

Usage

comment_link( $comment );
$comment(int|WP_Comment)
Comment object or ID.
Default: global comment object

Examples

0

#1 Output a link to the current comment in the loop

Create an anchored permalink to a single comment.

<a href="<?php comment_link() ?>">Link to this comment</a>

The code shown above will result (depending on your permalink settings) in something like this:

<a href="http://example.com//example-post/comment-page-2/#comment-3">Link to this comment</a>

Changelog

Since 1.5.0 Introduced.
Since 4.4.0 Introduced the $comment argument.

comment_link() code WP 6.4.3

function comment_link( $comment = null ) {
	/**
	 * Filters the current comment's permalink.
	 *
	 * @since 3.6.0
	 *
	 * @see get_comment_link()
	 *
	 * @param string $comment_permalink The current comment permalink.
	 */
	echo esc_url( apply_filters( 'comment_link', get_comment_link( $comment ) ) );
}