钩子文档

saved_{$taxonomy}

💡 云策文档标注

概述

saved_{$taxonomy} 是一个 WordPress Hook,在特定分类法中的术语保存且术语缓存清除后触发。Hook 名称的动态部分 $taxonomy 指分类法 slug,例如 saved_category 或 saved_post_tag。

关键要点

  • 触发时机:在术语保存并清除缓存后执行。
  • 参数:包括 $term_id(术语 ID)、$tt_id(术语分类法 ID)、$update(是否更新现有术语)和 $args(传递给 wp_insert_term() 的参数数组)。
  • 相关函数:与 wp_update_term() 和 wp_insert_term() 关联使用。
  • 版本变更:6.1.0 版本添加了 $args 参数,5.5.0 版本引入此 Hook。

代码示例

do_action( "saved_{$taxonomy}", $term_id, $tt_id, false, $args );

📄 原文内容

Fires after a term in a specific taxonomy has been saved, and the term cache has been cleared.

Description

The dynamic portion of the hook name, $taxonomy, refers to the taxonomy slug.

Possible hook names include:

  • saved_category
  • saved_post_tag

Parameters

$term_idint
Term ID.
$tt_idint
Term taxonomy ID.
$updatebool
Whether this is an existing term being updated.
$argsarray
Arguments passed to wp_insert_term() .

More Arguments from wp_insert_term( … $args )

Array or query string of arguments for inserting 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( "saved_{$taxonomy}", $term_id, $tt_id, false, $args );

Changelog

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