钩子文档

comment_url

💡 云策文档标注

概述

comment_url 是一个 WordPress 过滤器,用于在显示评论作者 URL 时进行过滤。它允许开发者修改或处理评论作者的 URL 值。

关键要点

  • 过滤器名称:comment_url
  • 参数:$comment_author_url(评论作者 URL 字符串)和 $comment_id(评论 ID 作为数字字符串)
  • 应用示例:通过 apply_filters 调用,例如在 comment_author_url() 函数中
  • 版本历史:从 WordPress 1.2.0 引入,4.1.0 版本添加了 $comment_id 参数

代码示例

echo apply_filters( 'comment_url', $comment_author_url, $comment->comment_ID );

注意事项

  • 此过滤器主要用于显示目的,不直接链接 URL
  • 相关函数:comment_author_url() 用于显示当前评论作者的 URL

📄 原文内容

Filters the comment author’s URL for display.

Parameters

$comment_author_urlstring
The comment author’s URL.
$comment_idstring
The comment ID as a numeric string.

Source

echo apply_filters( 'comment_url', $comment_author_url, $comment->comment_ID );

Changelog

Version Description
4.1.0 The $comment_id parameter was added.
1.2.0 Introduced.