钩子文档

comment_form_field_{$name}

💡 云策文档标注

概述

comment_form_field_{$name} 是一个 WordPress 过滤器钩子,用于自定义评论表单字段的显示输出。它允许开发者修改特定字段的 HTML 内容,如评论、作者、邮箱等。

关键要点

  • 这是一个动态钩子,$name 部分对应评论表单字段的名称,例如 comment_form_field_comment、comment_form_field_author 等。
  • 参数 $field 是字段的 HTML 格式化输出字符串,开发者可以过滤并修改此内容。
  • 在 comment_form() 函数中调用,用于输出评论表单。
  • 自 WordPress 3.0.0 版本引入。

📄 原文内容

Filters a comment form field for display.

Description

The dynamic portion of the hook name, $name, refers to the name of the comment form field.

Possible hook names include:

  • comment_form_field_comment
  • comment_form_field_author
  • comment_form_field_email
  • comment_form_field_url
  • comment_form_field_cookies

Parameters

$fieldstring
The HTML-formatted output of the comment form field.

Source

echo apply_filters( "comment_form_field_{$name}", $field ) . "n";

Changelog

Version Description
3.0.0 Introduced.