钩子文档

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_category
  • edit_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_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_{$taxonomy}", $term_id, $tt_id, $args );

Changelog

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

User Contributed Notes