get_comments_link()

最后更新于:2021-11-26 07:58:18

get_comments_link( int|GC_Post$post_id)

Retrieves the link to the current post comments.

参数

$post_id

(int|GC_Post) (Optional) Post ID or GC_Post object. Default is global $post.

响应

(string) The link to the comments.

源文件

文件: gc-includes/comment-template.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|GC_Post $post_id       Post ID or GC_Post object.
	 */
	return apply_filters( 'get_comments_link', $comments_link, $post_id );
}