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.
Source
$terms_to_edit = apply_filters( 'terms_to_edit', $terms_to_edit, $taxonomy );
Changelog
| Version | Description |
|---|---|
| 2.8.0 | Introduced. |
Skip to note 2 content
Steven Lin
Example Migrated from Codex:
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; }