edited_term
云策文档标注
概述
edited_term 是一个 WordPress 动作钩子,在术语更新且缓存清理后触发。它允许开发者执行自定义操作,并提供了针对特定分类法的钩子变体。
关键要点
- edited_term 钩子在术语更新后触发,确保缓存已清理。
- edited_$taxonomy 钩子可用于针对特定分类法,其中 $taxonomy 是分类法 slug。
- 参数包括 $term_id(术语 ID)、$tt_id(术语分类法 ID)、$taxonomy(分类法 slug)和 $args(传递给 wp_update_term() 的参数数组)。
- args 参数从 WordPress 6.1.0 版本开始添加,包含 alias_of、description、parent 和 slug 等字段。
- 相关函数 wp_update_term() 用于更新术语,基于提供的参数。
代码示例
do_action( 'edited_term', $term_id, $tt_id, $taxonomy, $args );注意事项
- 此钩子自 WordPress 2.3.0 版本引入,$args 参数在 6.1.0 版本中添加。
- 使用 edited_$taxonomy 钩子时,需替换 $taxonomy 为具体分类法 slug,以精确控制触发条件。
原文内容
Fires after a term has been updated, and the term cache has been cleaned.
Description
The ‘edited_$taxonomy’ hook is also available for targeting a specific taxonomy.
Parameters
$term_idint-
Term ID.
$tt_idint-
Term taxonomy ID.
$taxonomystring-
Taxonomy slug.
$argsarray-
Arguments passed to wp_update_term() .
More Arguments from wp_update_term( … $args )
Array of arguments for updating a term.
alias_ofstringSlug of the term to make this term an alias of.
Accepts a term slug.descriptionstringThe term description.parentintThe id of the parent term. Default 0.slugstringThe term slug to use.
Source
do_action( 'edited_term', $term_id, $tt_id, $taxonomy, $args );