函数文档

comments_link()

💡 云策文档标注

概述

comments_link() 是一个 WordPress 模板标签,用于输出当前文章评论链接的 HTML。该函数已弃用两个参数,直接调用即可安全使用。

关键要点

  • 功能:显示当前文章评论的链接,输出已转义的 URL。
  • 参数:$deprecated 和 $deprecated_2 均为已弃用参数,不应使用,函数内部会调用 _deprecated_argument() 处理。
  • 实现:函数内部调用 get_comments_link() 获取链接,并通过 esc_url() 进行转义后输出。
  • 相关函数:与 get_comments_link()、esc_url() 和 _deprecated_argument() 紧密相关。

代码示例

// 在模板中直接调用 comments_link() 输出评论链接
comments_link();

注意事项

输出已由 WordPress 核心转义,无需额外处理。避免使用已弃用的参数。


📄 原文内容

Displays the link to the current post comments.

Parameters

$deprecatedstringrequired
Not Used.
$deprecated_2stringrequired
Not Used.

Source

function comments_link( $deprecated = '', $deprecated_2 = '' ) {
	if ( ! empty( $deprecated ) ) {
		_deprecated_argument( __FUNCTION__, '0.72' );
	}
	if ( ! empty( $deprecated_2 ) ) {
		_deprecated_argument( __FUNCTION__, '1.3.0' );
	}
	echo esc_url( get_comments_link() );
}

Changelog

Version Description
0.71 Introduced.

User Contributed Notes