edit_{$taxonomy}
云策文档标注
概述
edit_{$taxonomy} 是一个 WordPress 动作钩子,在特定分类法中的术语更新后、术语缓存清理前触发。钩子名称的动态部分 $taxonomy 指分类法 slug,例如 edit_category 或 edit_post_tag。
关键要点
- 触发时机:在术语更新后、缓存清理前执行,适用于更新后的自定义处理。
- 动态钩子名称:基于 $taxonomy 参数动态生成,如 edit_category 用于分类法 category。
- 参数:$term_id(术语 ID)、$tt_id(术语分类法 ID)、$args(传递给 wp_update_term() 的参数数组)。
- 版本变化:$args 参数在 WordPress 6.1.0 中添加,钩子自 2.3.0 版本引入。
注意事项
- 回调函数接收 3 个参数,第三个参数 $args 仅在 WP 6.1 及以上版本可用。
- 钩子常用于在术语更新后执行额外逻辑,如数据同步或日志记录。
原文内容
Fires after a term in a specific taxonomy has been updated, but before the term cache has been cleaned.
Description
The dynamic portion of the hook name, $taxonomy, refers to the taxonomy slug.
Possible hook names include:
edit_categoryedit_post_tag
Parameters
$term_idint-
Term ID.
$tt_idint-
Term taxonomy ID.
$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( "edit_{$taxonomy}", $term_id, $tt_id, $args );
Skip to note 2 content
mujuonly
The callback function receives 3 arguments. The third parameter $args is added in WP 6.1.