钩子文档

edit_term_taxonomy

💡 云策文档标注

概述

edit_term_taxonomy 是一个 WordPress 动作钩子,在术语-分类法关系更新前立即触发。它允许开发者在术语更新过程中执行自定义操作。

关键要点

  • 触发时机:在术语-分类法关系更新前立即执行。
  • 参数:$tt_id(术语分类法 ID)、$taxonomy(分类法 slug)、$args(传递给 wp_update_term() 的参数数组)。
  • 用途:常用于更新术语计数或执行其他与术语相关的自定义逻辑。
  • 版本历史:从 WordPress 2.9.0 引入,6.1.0 版本添加了 $args 参数。

代码示例

do_action( 'edit_term_taxonomy', $tt_id, $taxonomy, $args );

注意事项

  • $args 参数包含 alias_of、description、parent、slug 等字段,用于控制术语更新行为。
  • 相关函数包括 _update_post_term_count()、_update_generic_term_count() 和 wp_update_term(),用于术语计数和更新操作。

📄 原文内容

Fires immediate before a term-taxonomy relationship is updated.

Parameters

$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_of string
    Slug of the term to make this term an alias of.
    Accepts a term slug.
  • description string
    The term description.
  • parent int
    The id of the parent term. Default 0.
  • slug string
    The term slug to use.

Source

do_action( 'edit_term_taxonomy', $tt_id, $taxonomy, $args );

Changelog

Version Description
6.1.0 The $args parameter was added.
2.9.0 Introduced.