WordPress at a glance

get_comments_link() WP 1.0

Retrieves the link to the current post comments.

Is the basis for: comments_link()
Works based on: get_permalink()

No Hooks.

Return

String. The link to the comments.

Usage

get_comments_link( $post_id );
$post_id(int/WP_Post)
Post ID or WP_Post object.
Default: global $post

Code of get_comments_link: wp-includes/comment-template.php VER 5.0

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

Related Functions

From tag: Comments

More from tag: Link (URL)

More from category: Comments

No comments
    Hello, !     Log In . Register