get_comments_link() – Retrieves the link to the current post comments.

You appear to be a bot. Output may be restricted

Description

Retrieves the link to the current post comments.

Usage

$string = get_comments_link( $post_id );

Parameters

$post_id
( int|WP_Post ) optional – Optional. Post ID or WP_Post object. Default is global $post.

Returns

string The link to the comments.

Source

File name: wordpress/wp-includes/comment-template.php
Lines:

1 to 14 of 14
function get_comments_link( $post_id = 0 ) {
  $hash          = get_comments_number( $post_id ) ? '#comments' : '#respond';
  $comments_link = get_permalink( $post_id ) . $hash;

  
/**
 * 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_id       Post ID or WP_Post object.
 */
  return apply_filters( 'get_comments_link', $comments_link, $post_id );
}
 

 View on GitHub View on Trac