comment_link
云策文档标注
概述
comment_link 是一个 WordPress 过滤器,用于修改 RSS 源中评论的永久链接。它允许开发者通过自定义函数来调整评论链接的输出。
关键要点
- comment_link 过滤器用于过滤当前评论的永久链接,主要应用于 RSS 源中。
- 过滤器接收一个参数:$comment_permalink(当前评论链接),并必须返回处理后的链接值。
- 使用 add_filter 钩子注册自定义函数,函数名需唯一,避免与其他函数冲突。
代码示例
add_filter( 'comment_link', 'filter_function_name', 10, 3 );
function filter_function_name( $link ) {
// 操作评论链接
return $link;
}注意事项
- 自定义函数必须返回一个值,否则输出可能为空。
- 函数名 filter_function_name 应替换为唯一的名称,不能与已声明的其他函数重复。
- 此过滤器在 WordPress 3.6.0 版本中引入。
原文内容
Filters the current comment’s permalink.
Description
See also
Parameters
$comment_permalinkstring-
The current comment permalink.
Source
echo esc_url( apply_filters( 'comment_link', get_comment_link( $comment ) ) );
Changelog
| Version | Description |
|---|---|
| 3.6.0 | Introduced. |