函数原型
get_comments_link( int|WP_Post $post ): string
函数描述
Retrieves the link to the current post comments.
是否弃用
未弃用
函数参数
-
$post
int|WP_Post
Optional - Post ID or WP_Post object. Default is global $post.
函数返回值
string The link to the comments.
函数位置
File: wp-includes/comment-template.php.
函数源码
function get_comments_link( $post = 0 ) {
$hash = get_comments_number( $post ) ? '#comments' : '#respond';
$comments_link = get_permalink( $post ) . $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 Post ID or WP_Post object.
*/
return apply_filters( 'get_comments_link', $comments_link, $post );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |

