钩子文档

get_comments_link

💡 云策文档标注

概述

get_comments_link 是一个 WordPress 过滤器钩子,用于修改返回的文章评论固定链接。它允许开发者自定义评论链接的生成方式。

关键要点

  • 过滤器名称:get_comments_link
  • 参数:$comments_link(字符串,带 '#comments' 后缀的评论固定链接)和 $post(整数或 WP_Post 对象,文章 ID 或文章对象)
  • 源调用:apply_filters('get_comments_link', $comments_link, $post)
  • 相关函数:get_comments_link() 用于检索当前文章评论链接
  • 引入版本:WordPress 3.6.0

📄 原文内容

Filters the returned post comments permalink.

Parameters

$comments_linkstring
Post comments permalink with '#comments' appended.
$postint|WP_Post
Post ID or WP_Post object.

Source

return apply_filters( 'get_comments_link', $comments_link, $post );

Changelog

Version Description
3.6.0 Introduced.