钩子文档

terms_to_edit

💡 云策文档标注

概述

terms_to_edit 过滤器用于修改在编辑文章页面中,分类法侧边栏显示的可用术语的逗号分隔列表。它允许开发者在不改变术语行为的情况下,调整其视觉呈现,例如添加前缀。

关键要点

  • 过滤器名称:terms_to_edit
  • 用途:修改编辑界面中分类法术语的逗号分隔列表
  • 参数:$terms_to_edit(逗号分隔的术语名称字符串)和 $taxonomy(分类法名称)
  • 注意事项:返回的 CSV 会被 JavaScript 过滤并以纯文本渲染,因此包装术语的 HTML 不会生效

代码示例

add_filter('terms_to_edit','add_term_output');

function add_term_output($terms) {
   global $taxonomy;

   if( 'post_tag' === $taxonomy )
      return $terms.', New Term';
   else
      return $terms;
}

📄 原文内容

Filters the comma-separated list of terms available to edit.

Description

See also

Parameters

$terms_to_editstring
A comma-separated list of term names.
$taxonomystring
The taxonomy name for which to retrieve terms.

More Information

  • This filter is used to modify the CSV of terms that is used to show active terms in the taxonomy sidebars on the edit post screen.
  • This is primarily of use if you need to visually modify the appearance of an active term (such as prefixing an asterisk) without changing its behavior. Note that the returned CSV is filtered using JavaScript and is rendered in plain text, so wrapping terms in HTML will not work (any HTML will be rendered as text).

Source

$terms_to_edit = apply_filters( 'terms_to_edit', $terms_to_edit, $taxonomy );

Changelog

Version Description
2.8.0 Introduced.

User Contributed Notes