Filter hook 'get_comment_link'

in WP Core File wp-includes/comment-template.php at line 866

View Source

get_comment_link

Filter Hook
Description
Filters the returned single comment permalink.

Hook Information

File Location wp-includes/comment-template.php View on GitHub
Hook Type Filter
Line Number 866

Hook Parameters

Type Name Description
string $comment_link The comment permalink with '#comment-$id' appended.
WP_Comment $comment The current comment object.
array $args An array of arguments to override the defaults.
int $cpage The calculated 'cpage' value.

Usage Examples

Basic Usage
<?php
// Hook into get_comment_link
add_filter('get_comment_link', 'my_custom_filter', 10, 4);

function my_custom_filter($comment_link, $comment, $args, $cpage) {
    // Your custom filtering logic here
    return $comment_link;
}

Source Code Context

wp-includes/comment-template.php:866 - How this hook is used in WordPress core
<?php
 861  	 * @param string     $comment_link The comment permalink with '#comment-$id' appended.
 862  	 * @param WP_Comment $comment      The current comment object.
 863  	 * @param array      $args         An array of arguments to override the defaults.
 864  	 * @param int        $cpage        The calculated 'cpage' value.
 865  	 */
 866  	return apply_filters( 'get_comment_link', $comment_link, $comment, $args, $cpage );
 867  }
 868  
 869  /**
 870   * Retrieves the link to the current post comments.
 871   *

PHP Documentation

<?php
/**
	 * Filters the returned single comment permalink.
	 *
	 * @since 2.8.0
	 * @since 4.4.0 Added the `$cpage` parameter.
	 *
	 * @see get_page_of_comment()
	 *
	 * @param string     $comment_link The comment permalink with '#comment-$id' appended.
	 * @param WP_Comment $comment      The current comment object.
	 * @param array      $args         An array of arguments to override the defaults.
	 * @param int        $cpage        The calculated 'cpage' value.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 4
  • File: wp-includes/comment-template.php
Related Hooks

Related hooks will be displayed here in future updates.