comment_link() WordPress Function

The comment_link() function displays a link to the current comment. This is useful for permalinks to specific comments. The comment_link() function can be used in both the loop and outside the loop.

comment_link( int|WP_Comment $comment = null ) #

Display the link to the comments.


Parameters

$comment

(int|WP_Comment)(Optional) Comment object or ID. Defaults to global comment object.

Default value: null


Top ↑

Source

File: wp-includes/feed.php

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


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Introduced the $comment argument.
1.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.