钩子文档

term_{$field}

💡 云策文档标注

概述

此文档介绍 WordPress 中的 term_{$field} 过滤器,用于在显示前对分类术语字段值进行过滤和清理。过滤器名称的动态部分 $field 对应术语字段名。

关键要点

  • 过滤器名称:term_{$field},其中 $field 是动态的术语字段名
  • 参数:$value(字段值)、$term_id(术语ID)、$taxonomy(分类法slug)、$context(上下文)
  • 用途:在 sanitize_term_field() 函数中调用,用于清理术语字段值
  • 注意事项:使用 name 字段时需小心,存在另一个 term_name 过滤器,参数不同

注意事项

  • 使用 name 字段时,注意 term_name 过滤器参数不同,建议查看 Trac 票证获取详情

📄 原文内容

Filters the term field sanitized for display.

Description

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

Parameters

$valuemixed
Value of the term field.
$term_idint
Term ID.
$taxonomystring
Taxonomy slug.
$contextstring
Context to retrieve the term field value.

Source

$value = apply_filters( "term_{$field}", $value, $term_id, $taxonomy, $context );

Changelog

Version Description
2.3.0 Introduced.

User Contributed Notes