comment_link( int|WP_Comment $comment = null )

Displays the link to the comments.

Parameters

$commentint|WP_Commentoptional
Comment object or ID. Defaults to global comment object.

Default:null

Source

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 ) ) );
}

Hooks

apply_filters( ‘comment_link’, string $comment_permalink )

Filters the current comment’s permalink.

Changelog

VersionDescription
4.4.0Introduced the $comment argument.
1.5.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Create an anchored permalink to a single comment.

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

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

    <a href="http://example.com/2009/07/15/example-post/comment-page-1/#comment-3">Permalink to this comment</a>

You must log in before being able to contribute a note or feedback.