get_comments_link

Advertisement

Summery Summery

Retrieves the link to the current post comments.

Syntax Syntax

get_comments_link( int|WP_Post $post_id )

Parameters Parameters

$post_id

(Optional) Post ID or WP_Post object. Default is global $post.

Return Return

(string) The link to the comments.

Source Source

File: wp-includes/comment-template.php

 *
 * @since 1.5.0
 *
 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
 * @return string The link to the comments.
 */
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

Advertisement

Changelog Changelog

Changelog
Version Description
1.5.0 Introduced.

Advertisement

Leave a Reply