Filter hook 'get_comments_link'

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

View Source

get_comments_link

Filter Hook
Description
Filters the returned post comments permalink.

Hook Information

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

Hook Parameters

Type Name Description
string $comments_link Post comments permalink with '#comments' appended.
int|WP_Post $post Post ID or WP_Post object.

Usage Examples

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

function my_custom_filter($comments_link, $post) {
    // Your custom filtering logic here
    return $comments_link;
}

Source Code Context

wp-includes/comment-template.php:889 - How this hook is used in WordPress core
<?php
 884  	 * @since 3.6.0
 885  	 *
 886  	 * @param string      $comments_link Post comments permalink with '#comments' appended.
 887  	 * @param int|WP_Post $post          Post ID or WP_Post object.
 888  	 */
 889  	return apply_filters( 'get_comments_link', $comments_link, $post );
 890  }
 891  
 892  /**
 893   * Displays the link to the current post comments.
 894   *

PHP Documentation

<?php
/**
	 * Filters the returned post comments permalink.
	 *
	 * @since 3.6.0
	 *
	 * @param string      $comments_link Post comments permalink with '#comments' appended.
	 * @param int|WP_Post $post          Post ID or WP_Post object.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/comment-template.php
Related Hooks

Related hooks will be displayed here in future updates.